File To Stream - Stream To File

G

Giuseppe

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
 
C

Cor Ligthert

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
 
C

Cor Ligthert

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
 

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

Similar Threads


Top