|
I am puzzled on how to proceede with this issue! I have a text file that has information that I would like to extract out and save to another file.
I am able to read the file and write the file I am having a hard time figureing out how to extract the data I want out.
Any help would be greatly appreciated
Thank you
Hella
|
|
|
|
|
If it's a text file,
string textInFile = System.IO.File.ReadAllText("thefile.txt");
System.IO.File.WriteAllText(textInFile);
|
|
|
|
|
Sorry, I should have clearified a bit more...
I have no problem reading the file and writing the file! The only thing is I don't want to print out all the contents of the file just specific text in the text file.
From my example file I would want to get the Time and this ftp: 6384000 bytes sent in 84.73Seconds 75.35Kbytes/sec.
Once I figure out how to parse out this info I can acomplish the rest. I am pretty sure I have to use an array... But array's are a little tricky for me.
The text file I would like to pick a part!
05:29 PM
ftp> Connected to 192.168.100.115.
open 192.168.100.115
220 Connected to Intermec IFTP server. Version 2.11.
User (192.168.100.115:(none)):
331 Password required!
230-===============================
Intermec FTP server ready!
Version 2.11. WINCE
0010400D7B4C 36310500129 730
Binary transfer mode only!
===============================
230 Logon successful.
ftp> Local directory now C:\Documents and Settings\burlagr\Desktop\FTP_Transfer\Files.
ftp> lcd "C:\Documents and Settings\burlagr\Desktop\FTP_Transfer\Files"
cd "Flash File Store"
250 Current directory changed to "/Flash File Store/".
ftp> binary
200 Type set to I.
ftp> Hash mark printing On ftp: (2048 bytes/hash mark) .
ftp> hash
ftp>
mput test88.txt
mput test88.txt? yes
200 Port command successful.
150 STOR: Command accepted!
########################################################################################################################################################################################################################################################################################################################################################################################################
226 Transfer Complete.
ftp: 6384000 bytes sent in 84.73Seconds 75.35Kbytes/sec.
ftp> ftp>
|
|
|
|
|
|
Unfortunatley the data is not a .csv file... But would it be easier if I just concerted the .txt file over to a csv file? So there is whitespace that I have to deal with.
|
|
|
|
|
The Regex pattern could get as detailed as you like.
Untested:
<br />
using (StreamReader sr = new StreamReader("File.txt")) <br />
{<br />
string line;<br />
while ((line = sr.ReadLine()) != null) <br />
{<br />
if Regex.IsMatch(line, @"\d+ bytes sent")<br />
Console.WriteLine(line);<br />
}<br />
}<br />
- Bitwise
|
|
|
|
|
Thanks for all the help Bitwise...... This seems to easy though. Is this the bestway to implement this?
|
|
|
|
|
I have a server which updates programs on our local network, informs of notifications, etc... The problem is that after so long it will "lock up" and stop accepting connections. I have connected/disconnected clients and tested everywhere for a solution to the problem. There is actually a series of about 6 servers on different ports, and all of them quit accepting at once. The MainSocket is using Socket.BeginAccept and waiting for connections, then passes them off to a data structure I created to maintain the connections/user info/etc. Is there a certain period of "idle time" when the Framework aborts that thread? It seems like if that were the case, however, you wouldnt even be able to connect to the server. As it is, you can get a connection, you just cant communicate. I know without seeing the code it may be hard to determine a solution, but Im not sure exactly what the problem is. Any thoughts or comments would be appreciated...
Aaron
|
|
|
|
|
did you say that all disconnect or stop accepting connections at the same time? Have you tried running the server and client on your machine to see if they stay up and running?
What about traping the socket errors are they reporting anything?
T
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Yes, that is how I tested them to get the bugs out (On My Machine). It takes a good 2 days or so before they stop accepting connections, however, and debugging for that long really isnt feasible, because it doesnt always happen. It does report errors, but the error logs dont report anything unusual, client connected/disconnected, updating database, etc. Nothing that should clog the server like that. Thanks...
Aaron
|
|
|
|
|
How are you running this? Windows service? ASP.NET? Windows app? Command line? Different/same PC?
Maybe the hardware is going into power saving mode...
|
|
|
|
|
I created a tabbed app that has a number of checkboxes on the second tab. I'm using currency manager to keep track of the number of records that are currently in the DB as well as adding, deleting records. I also am using data view to sort my records based on what the end user is looking for.
When I go to add a new record and click on the second tab, I get a DBNull exception.
I've made sure that the fields in the database are set to not allow nulls, and with a default value of zero.
I want to do a check to make sure that if the field is null then the binded field = false?
Or is there a better way to do this?
Thanks
Tom Wright
tawright915@yahoo.com
-- modified at 15:13 Wednesday 12th April, 2006
|
|
|
|
|
To Check if a field's value is null:
dataset.tables[0].row[0]["Field_Name"] == DBNull.Value
Was it a cat I saw?
|
|
|
|
|
Thanks but I ended up fixing my problem this way.
Right before I add a new record I set the default value of the columns
ds.Tables[0].Columns["FieldName"].DefaultValue = false;
This seems to have done the trick.
Now I'm having problems saving mulitpule times on the same record.
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
when i try to make new class or project this error appear: "Automation server can't create object" . i try to reinstall VS2003 but this is not a solution for me..this is the error.
"Automation server can't create object"
i searced the messages but cant find anything about this..
thakns for now..
hasan tayyar
|
|
|
|
|
how create a toolbar that is active when the main window is active then deactive when the main is so too?
p.s. i want it will be conform to windows xp and vista.
tnx
|
|
|
|
|
Please help this. There are 2 errors at Thread creation.
I'd like to pass ArrayList to thread.
using System;<br />
using System.Threading;<br />
using System.Collections;<br />
namespace ConsoleApplication2<br />
{<br />
class Program<br />
<br />
{<br />
static object lockObject;<br />
<br />
static void Main(string[] args)<br />
<br />
{ <br />
<br />
<br />
ArrayList space = new ArrayList(); <br />
<br />
for (int i = 1; i <= 10 ; i++)<br />
{<br />
space.Add(i);<br />
<br />
} <br />
<br />
lockObject = new object(); <br />
<br />
<br />
Thread t1 = new Thread(new ParameterisedThreadStart(AccessData)); t1.Start(space);<br />
<br />
Thread.Sleep(20*1000);<br />
<br />
}<br />
<br />
<br />
<br />
public static void AccessData(object param)<br />
{<br />
<br />
ArrayList list = (ArrayList)param;<br />
<br />
lock (lockObject)<br />
{<br />
Random rand = new Random();<br />
<br />
int x = rand.Next(list.Count);<br />
list.Remove(x);<br />
Console.WriteLine("x = " + x);<br />
<br />
int y = rand.Next(list.Count);<br />
list.Remove(y);<br />
Console.WriteLine("y = " + y);<br />
<br />
int newNumber = x + y;<br />
Console.WriteLine("newNumber = " + newNumber);<br />
<br />
list.Add(newNumber);<br />
<br />
<br />
<br />
foreach (int inte in list)<br />
Console.WriteLine(inte);<br />
<br />
}<br />
<br />
<br />
<br />
}<br />
<br />
}<br />
}<br />
eric
|
|
|
|
|
What are the 2 errors?
Which version of the .NET framework are you running? (ParameterizedThreadStart is only in version 2.0 or higher)
|
|
|
|
|
Ah
The type or namespace name ParameterisedThreadStart could not be found
I use 1.1
So how I can get rid of that.
Please help
eric
|
|
|
|
|
get VS05 and use the 2.0 framework or find the 1.1 equivilant to the code.
|
|
|
|
|
Well, I just got the same errors in VS.Net 2005
So it's not because of the framework version then
Please help
eric
|
|
|
|
|
Make sure you've got
using System.Threading;
at the top of your .cs file where you use ParameterizedThreadStart.
You can read more about it here[^].
There are several alternatives though, including some that work on all .NET versions. Here's another way of starting a new thread, using Delegate.BeginInvoke:
public class MyClass
{
public delegate void FunctionThatTakesAnArrayList(ArrayList argument);
...
void StartTheThread()
{
FunctionThatTakesAnArrayList function = ThreadedArrayListUsage;
function.BeginInvoke(myArrayList, null, null);
}
void ThreadedArrayListUsage(ArrayList list)
{
}
}
Here's another way, using the .NET thread pool:
void StartTheThread()
{
System.Threading.ThreadPool.QueueUserWorkItem(ThreadedArrayListUsage, myArrayList);
}
void ThreadedArrayListUsage(object state)
{
ArrayList list = (ArrayList)state;
}
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: I luv teh choco
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
Thanks so much
I'm doing now
eric
|
|
|
|
|
Hi:
I selected Tooltip from the toolbox and clicked on the form and then for the contriols I want a tooltip, I went to the properties and entered the text I want to show (I tried with an without double quotes).
But I cant get the tooltip to show up. Please could you tell me if I am missing doing something?
Thanks, smurfy
|
|
|
|
|
Hey Smurfy,
Are you talking about Windows or Web application?
Manas
|
|
|
|