Click here to Skip to main content
16,017,745 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralKilling child processes Pin
Sam Marrocco2-May-05 8:29
Sam Marrocco2-May-05 8:29 
GeneralGet variables set in a SUB Pin
mike2k52-May-05 8:19
mike2k52-May-05 8:19 
GeneralRe: Get variables set in a SUB Pin
Het21092-May-05 18:48
Het21092-May-05 18:48 
GeneralSeperate decimal from whole number Pin
vertig07302-May-05 7:19
vertig07302-May-05 7:19 
GeneralRe: Seperate decimal from whole number Pin
chrismerrill2-May-05 7:49
chrismerrill2-May-05 7:49 
GeneralMortgage calulator loop question vb.net Pin
vb.net challenged2-May-05 6:16
vb.net challenged2-May-05 6:16 
GeneralHTML to IMAGE Pin
woklet2-May-05 5:02
woklet2-May-05 5:02 
GeneralStream problems Pin
CrazyEd161-May-05 23:35
CrazyEd161-May-05 23:35 
Hi Everybody,

I have a directory filled with files which are all exactly 1000 bytes big. What I need to do is simply to read the files in a stream one by one and to write them again in a different directory. I'd say this is a fairly standard operation, but for some reason, all my files come out of the process at 1001 bytes!! Am I missing something? Here is my code:

For Each f As IO.FileInfo In inDirInfo.GetFiles()
Dim str As New IO.FileStream(f.FullName, IO.FileMode.Open, IO.FileAccess.Read)
Dim chunk(str.Length) As Byte
str.Read(chunk, 0, chunk.Length)
str.Close()
Dim chunkStream As New IO.MemoryStream(chunk)
WriteStream(chunkStream, outputTempPath & "\" & f.Name)
chunkStream.Close()
Next

Private Sub WriteStream(ByVal stream As IO.Stream, ByVal path As String)
Try
Dim f As New IO.FileStream(path, IO.FileMode.Create)
Dim bytes(stream.Length) As Byte
stream.Read(bytes, 0, bytes.Length)
stream.Close()
f.Write(bytes, 0, bytes.Length)
f.Close()
Catch ex As Exception
Throw ex
End Try
End Sub

By the way, I don't want to simply copy the files, since I need to transfer them in streams.
Thanks for your help...

GeneralRe: Stream problems Pin
GeneralDisorder2-May-05 0:37
GeneralDisorder2-May-05 0:37 
GeneralProb in transferring ASP.NET Web Application Pin
vishalmishra1-May-05 23:15
vishalmishra1-May-05 23:15 
GeneralRe: Prob in transferring ASP.NET Web Application Pin
Christian Graus2-May-05 14:01
protectorChristian Graus2-May-05 14:01 
GeneralRe: Prob in transferring ASP.NET Web Application Pin
vishalmishra3-May-05 4:26
vishalmishra3-May-05 4:26 
GeneralRe: Prob in transferring ASP.NET Web Application Pin
Christian Graus3-May-05 13:18
protectorChristian Graus3-May-05 13:18 
GeneralCrystal Reports Pin
Madni Abbasi1-May-05 20:43
Madni Abbasi1-May-05 20:43 
Questionhow to assign NULL to Date Field ? Pin
Madni Abbasi1-May-05 20:37
Madni Abbasi1-May-05 20:37 
AnswerRe: how to assign NULL to Date Field ? Pin
Madni Abbasi1-May-05 21:11
Madni Abbasi1-May-05 21:11 
GeneralPicture box binding problem Pin
Binary01101-May-05 20:33
Binary01101-May-05 20:33 
GeneralRe: Picture box binding problem Pin
Madni Abbasi1-May-05 20:55
Madni Abbasi1-May-05 20:55 
GeneralRe: Picture box binding problem Pin
Anonymous1-May-05 21:07
Anonymous1-May-05 21:07 
GeneralRe: Picture box binding problem Pin
Madni Abbasi1-May-05 21:27
Madni Abbasi1-May-05 21:27 
GeneralRe: Picture box binding problem Pin
Binary01101-May-05 21:39
Binary01101-May-05 21:39 
GeneralRe: Picture box binding problem Pin
Binary01102-May-05 7:26
Binary01102-May-05 7:26 
Questionhow to write to a few clients in a socket,please Pin
jpartley1-May-05 18:00
jpartley1-May-05 18:00 
GeneralTo Mr. Dave.... Pin
vishalmishra1-May-05 9:11
vishalmishra1-May-05 9:11 
GeneralRe: To Mr. Dave.... Pin
Colin Angus Mackay1-May-05 10:28
Colin Angus Mackay1-May-05 10:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.