Read text file from local machine

  • Thread starter Thread starter Grey
  • Start date Start date
G

Grey

How to read a text file located in client machine with ASP.NET. the structure of the client text file is designed as follow:

PC1 abc 123.123.324
PC2 abd 123.56.78
PC3 hkk 79.39.20

each data was separated by Tab. My question is how can I read those data from the client text file and then display on the web with ASP.NET

Million Thanks
 
You have to make the client upload the text file first, and when uploaded. Then use this function:
' Returns the content of the specified text file

' Note: it can throw an exception
' Usage: Dim FileContent As String = LoadTextFile("C:\Autoexec.bat")

Function LoadTextFile(ByVal FilePath As String) As String
Dim sr As System.IO.StreamReader

Try
sr = New System.IO.StreamReader(FilePath)
LoadTextFile = sr.ReadToEnd()
Finally
If Not sr Is Nothing Then sr.Close()
End Try
End Function
to get the string (got this function from here: http://www.vb2themax.com/Item.asp?PageID=CodeBank&Cat=141&ID=490).
-- Fadi El-Eter, itoctopus - http://www.itoctopus.com
How to read a text file located in client machine with ASP.NET. the structure of the client text file is designed as follow:

PC1 abc 123.123.324
PC2 abd 123.56.78
PC3 hkk 79.39.20

each data was separated by Tab. My question is how can I read those data from the client text file and then display on the web with ASP.NET

Million Thanks
 
Back
Top