[RESOLVED] [2005] Listing remote Directory
Hi.. I'm new to visual basic, I'm now making a program to list files in remote directory, currently I'm using php to generate text file and my program to read the text file
I want to read file line by line from http://localhost/tes/view.txt
but it got stuck at this code
Code:
Dim objReader As New StreamReader("http://localhost/tes/view.txt")
It said URI format not supported.. How to make it support? Is there some way to read remote file text?
or is there some other way yo read files in directory?
Thanks..
Re: [2005] Listing remote Directory
You need to use a WebClient to download that file, then read it using streamreader. Something like this:
Code:
Using WC As New System.Net.WebClient()
Dim strem As IO.Stream = WC.OpenRead("put the address here")
Using reader As New System.IO.StreamReader(strem)
Dim line As String = String.Empty
While reader.Peek >= 0
line = reader.ReadLine()
'Do whatever you want with that line here
'
End While
End Using
End Using
Re: [2005] Listing remote Directory
Quote:
Originally Posted by stanav
You need to use a WebClient to download that file, then read it using streamreader. Something like this:
Code:
Using WC As New System.Net.WebClient()
Dim strem As IO.Stream = WC.OpenRead("put the address here")
Using reader As New System.IO.StreamReader(strem)
Dim line As String = String.Empty
While reader.Peek >= 0
line = reader.ReadLine()
'Do whatever you want with that line here
'
End While
End Using
End Using
Thanks a lot it's working.. :D
Re: [RESOLVED] [2005] Listing remote Directory
Hi LeonLanford,
you said you were trying to list remote directory with vb.net. I'm trying to do that but I haven“t found the way. Did you get it?
Thanks
Re: [RESOLVED] [2005] Listing remote Directory
I'm using php to generate file about the files and directory there and read the generated file..