By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,166 Members | 1,575 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,166 IT Pros & Developers. It's quick & easy.

File To Stream - Stream To File

P: n/a
Hello,

I Write this code for get Stream from a file :

Dim _Stream As Stream = New FileStream("C:\Test.bin", FileMode.Open,
FileAccess.Read)

This code for Put Stream to File :

Dim i As Integer
Dim fs As FileStream = New FileStream("C:\app\test.bin",
FileMode.CreateNew,FileAccess.Write)
Dim str As StreamReader = New StreamReader(_Stream)
Dim stw As StreamWriter = New StreamWriter(fs, System.Text.Encoding.Unicode)
stw.BaseStream.Seek(0, SeekOrigin.End)
stw.Write(Str.ReadToEnd())
fs.Close()
Str.Close()

Not Works ....

Where i'm Wrong
Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Giuseppe,

I tried your code, (with existing folders and file) and it did work fine for
me

Although file.copy(old,new) is in this case of course an easier command.

:-)

I hope this helps,

Cor

"Giuseppe" <pe***@msn.com> schreef in bericht
news:O5**************@TK2MSFTNGP15.phx.gbl...
Hello,

I Write this code for get Stream from a file :

Dim _Stream As Stream = New FileStream("C:\Test.bin", FileMode.Open,
FileAccess.Read)

This code for Put Stream to File :

Dim i As Integer
Dim fs As FileStream = New FileStream("C:\app\test.bin",
FileMode.CreateNew,FileAccess.Write)
Dim str As StreamReader = New StreamReader(_Stream)
Dim stw As StreamWriter = New StreamWriter(fs,
System.Text.Encoding.Unicode)
stw.BaseStream.Seek(0, SeekOrigin.End)
stw.Write(Str.ReadToEnd())
fs.Close()
Str.Close()

Not Works ....

Where i'm Wrong

Nov 21 '05 #2

P: n/a
I must send it to a remote server..

Nov 21 '05 #3

P: n/a
Giuseppe,
I must send it to a remote server..


In your sample you are showing from C:\xxx to C:\xxx

Why are you showing that, just to have fun that we try to help you?

Cor
Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.