|
-
Dec 18th, 2002, 10:06 AM
#1
Thread Starter
Member
Saving Files from a WebServer
I know how to get a System.IO.Stream of the file i need from my webserver, but what I'm a little lost on is how do I then take that stream and save it to a file? I actually need to save it over a file that already exists on the local hard drive.
I haven't uses IO stuff much, so I'm a bit lost
-
Dec 18th, 2002, 10:40 AM
#2
Registered User
Create a StreamReader (maybe BinareReader) to read from your stream and then use a StreamWrter (maybe BinaryWriter) to write to a FileStream object. Something like this (you didn't have a filestream as source, but that shouldn't matter).....
Code:
Dim fsr As New System.IO.FileStream("D:\savedPic.gif", IO.FileMode.Open)
Dim fsw As New System.IO.FileStream("D:\pic2.gif", IO.FileMode.Create)
Dim br As New System.IO.BinaryReader(fsr)
Dim bw As New System.IO.BinaryWriter(fsw)
bw.Write(br.Read)
-
Dec 18th, 2002, 01:07 PM
#3
Thread Starter
Member
cool, thanx, i'll give that a go!
i was trying sort of the same thing, but longer (looping through each byte and writing it to the new stream), but if your way works, it's a lot shorter and i'll use that
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|