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

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)
 
H

Herfried K. Wagner [MVP]

* 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?
 
T

Tom Spink

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
 
J

Jay B. Harlow [MVP - Outlook]

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top