hello !
this is my code , i am writing a text file form the datagrid, but this code is very slow , please check it out and give me some advice how i can make my code fast ,
If IO.File.Exists("C:\Customers.txt") = False Then
IO.File.Create("C:\Customers.txt")
End If
Dim FILE_NAME As String = "C:\Customers.txt"
If System.IO.File.Exists(FILE_NAME) = True Then
Dim objWriter As New System.IO.StreamWriter(FILE_NAME)
Dim i As Integer
Dim strheading As String
strheading = "CustomerID CustomerName"
objWriter.WriteLine(strheading)
For i = 0 To dgvMain.Rows.Count - 1
Dim str As String
str = dgvMain.Item(0, i).Value.ToString() & " " & dgvMain.Item(1, i).Value.ToString()
objWriter.WriteLine(str)
Next
objWriter.Close()
if you have better code then this please show me so that i can complete my current task.
Best Regards
Muhammad Waqas Aslam