|
-
Jan 2nd, 2010, 07:48 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Split texts files
Well, i have to translate this vb6 code:
Code:
ff = FreeFile
Open App.Path & "\UpdateArcadePT\ListaUpdate.dat" For Binary As #ff
URL = Space$(LOF(ff))
Get #ff, , URL
Close #ff
If URL = "" Then
Unload Me
Else
strLines = Split(URL, vbNewLine)
For i = LBound(strLines) To UBound(strLines)
If Len(strLines(i)) > 0 Then
strParts = Split(strLines(i), ";")
File.Caption = "Downloading " & strParts(1)
......
To C#, i have made this so far:
Code:
StreamReader objReader = new StreamReader(Environment.CurrentDirectory + @"\update\files.dat");
string sLine = objReader.ReadToEnd();
objReader.Close();
string[] pedacos = sLine.Split('\n');
for (Int32 i = 0; i < pedacos.Count(); i++)
{
string[] partes = pedacos.ToString().Split(new char[] {';'});
MessageBox.Show(partes.ToString());
}
The txt files is in the format:
1;name.rar;http://somesite
2;name2.rar;http://somesite
But the messagebox is returnig: System.String[].
Any help?
Last edited by lelejau; Jan 2nd, 2010 at 09:03 PM.
-
Jan 2nd, 2010, 09:23 PM
#2
Re: Split texts files
csharp Code:
string path = Path.Combine(Application.StartupPath, @"update\files.dat"); foreach (string line in File.ReadAllLines(path)) { string[] fields = line.Split(';'); MessageBox.Show(fields[0]); }
Note that the file, according to the original code, is in the application's startup folder, NOT the current directory, which may or may not be the same path.
-
Jan 3rd, 2010, 05:06 PM
#3
Thread Starter
Hyperactive Member
Re: Split texts files
Thanks for the help, i got it just fixing this line:
string[] partes = pedacos[i].ToString().Split(new char[] {';'});
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|