How can I 'read'/'write' a file with a url address?

  • Thread starter Thread starter Trint Smith
  • Start date Start date
T

Trint Smith

Is there anything like this that will allow a url address instread of a
drive letter?:

Dim fw As StreamWriter
fw = New StreamWriter("D:\file.txt", True)
fw.WriteLine(ex)
fw.Close()

The reason I need to do this is it has to be done on the web server.
Thanks,
Trint

.Net programmer
(e-mail address removed)
 
* Trint Smith said:
Is there anything like this that will allow a url address instread of a
drive letter?:

Dim fw As StreamWriter
fw = New StreamWriter("D:\file.txt", True)
fw.WriteLine(ex)
fw.Close()

The reason I need to do this is it has to be done on the web server.

Why not download the file, modify it, and then upload it again?
 
Not really, as the URI will most likely specify an HTTP protocol, which only
allows uploading of data through a POST method, and hence there's no way to
write a file. There is a way to read from a URI, however, and I'm sure it's
along the same lines as what you're doing there.

--
HTH,
-- Tom Spink, Über Geek

Woe be the day VBC.EXE says, "OrElse what?"

Please respond to the newsgroup,
so all can benefit
 
Trint,
You can use a StreamWriter to indirectly write to a URL.

The easiest way is to use WebClient.OpenWrite to get a writable Stream, that
you then pass to the StreamWriter class...

Something like (syntax checked only):

Imports System.Net
Imports System.IO

Dim url As String
Dim client As New WebClient()
Dim stream As Stream = client.OpenWrite(url)
Dim writer As New StreamWriter(stream)

A more complicated way is to use a WebRequest & WebResponse, however the
WebClient hides most of the details of the WebRequest & WebResponse classes.

Hope this helps
Jay
 
Back
Top