sarada

sarada

  • NA
  • 34
  • 0

can u give the working code for this in c#

May 23 2009 1:12 AM

hi,

If File.Exists("F:\User.txt") Then
'Load user accounts
Dim sr As StreamReader = New StreamReader("F:\user.txt")
Dim sInput As String = ""
Dim ThisRow() As String
Dim sData() As String
Dim i As Integer
'//=Read all Data into sInput
Do While sr.Peek >= 0
sInput = sInput & sr.ReadLine & ControlChars.CrLf
Loop

ThisRow = Split(sInput, vbCrLf)

For i = 0 To UBound(ThisRow) - 1
sData = Split(ThisRow(i), ",")
Dim lsvi As New ListViewItem(sData, 2)
ListView1.Items.Add(lsvi)
Next

ListView1.Sort()
sr.Close()
End If


i tried with this it is not working at Split

if (File.Exists("F:\\User.txt"))

{

//Load user accounts

StreamReader sr = new StreamReader("F:\\user.txt");

string sInput = "";

string[] ThisRow = null;

string[] sData = null;

int i = 0;

////=Read all Data into sInput

if (sr.Peek() >= 0)

{

sInput = sInput + sr.ReadLine() + "\r\n";

}

ThisRow = sInput.Split("\r\n",ThisRow);

int temp = ThisRow.GetUpperBound(1);

for (i = 0; i <= temp - 1; i++)

{

sData = Strings.Split(ThisRow(i), ",");

ListViewItem lsvi = new ListViewItem(sData, 2);

listView1.Items.Add(lsvi);

}

listView1.Sort();

sr.Close();

}


Answers (3)