Click to See Complete Forum and Search --> : split function
PT Exorcist
Nov 24th, 2002, 12:26 PM
i wanna split a string with the split functions by spliting by the "large" keyword...i tryed making
myString.Split("large");
and it didnt work..it says it needs an char array... i made one but he keeps only loooking for the 1st letter of the split string(in this case l)..what am i doin wrong?
kovan
Nov 24th, 2002, 12:42 PM
System.Text.RegularExpression
Read on that.. Regex to be specific
PT Exorcist
Nov 24th, 2002, 12:42 PM
tyy
PT Exorcist
Nov 24th, 2002, 12:47 PM
i've asked myself what would mean the Regex.Split method when looking by info on msdn but never clicked in the link to that... lol
its workin like a sharm =)
PT Exorcist
Nov 24th, 2002, 12:50 PM
damn when trying in run-time it returned a System.IO.StreamReader... :confused:
kovan
Nov 24th, 2002, 12:55 PM
what u mean?
PT Exorcist
Nov 24th, 2002, 12:57 PM
nvm the problem was the string i was trying to split was saying that
PT Exorcist
Nov 24th, 2002, 01:10 PM
string fileName = @"C:\Documents and Settings\JBRANCO\Desktop\dev.txt";
string lol = System.IO.File.OpenText(fileName).ToString();
MessageBox.Show(lol);
this is returning System.io.streamreader...what am i doin wrong? invalid cast maybe..?
hellswraith
Nov 24th, 2002, 01:18 PM
Your going to want to do something like this:
string input = null;
// Open the file
try
{
System.IO.StreamReader re = System.IO.File.OpenText("YourFile");
// This will put the file as a string variable for you.
input = re.ReadToEnd();
// Close the streamreader.
re.Close();
}
catch
{
MessageBox.Show("File Problem");
}
PT Exorcist
Nov 24th, 2002, 01:21 PM
the problem is the same...it isnt as string format
hellswraith
Nov 24th, 2002, 01:30 PM
Did you do what I did in my post? If the file your opening is a text file, then use what I posted. When you use the OpenText method, it returns a streamreader. You then need to tell the streamreader to give you text. That is what this line does:
input = re.ReadToEnd();
input is a string variable.
hellswraith
Nov 24th, 2002, 01:33 PM
//Check your file name and path, it looks incorrect to me
string fileName = @"C:Documents and Settings\JBRANCODesktopdev.txt";
string text;
StreamReader re = System.IO.File.OpenText(fileName);
text = re.ReadToEnd();
re.Close();
MessageBox.Show(text);
PT Exorcist
Nov 24th, 2002, 01:35 PM
k tks worked
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.