473,387 Members | 1,453 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Array Byte To FileStream (to blocks)

Hello,

I a byte array and i put to remote class (to blocks)

I read byte array from a file :
dim fs as FileStream = File.Open(filename, FileMode.Open);
dim data() as byte = new byte(fs.Length){}
fs.Read(data, 0, data.Length)
fs.Close()

How write to blocks a array to File Stream?

I have Write this code byt not it works :

Dim i As Integer
Dim currentChunk As Integer=0
Dim buffsize As Integer = 4096
Dim fs As FileStream
Dim Data(buffsize) As Byte

fs = New FileStream("C:\fileDestination", FileMode.CreateNew)

Dim bw As BinaryWriter = New BinaryWriter(fs)

For i = 0 To arrayByte.Length / buffsize
currentChunk = (i * buffsize)
If currentChunk + buffsize > arrayByte.Length Then
buffsize = arrayByte.Length - currentChunk
End If
buffer.BlockCopy(arrayByte, currentChunk, Data, 0, buffsize)
bw.Write(Data)
Next

bw.Close()
Nov 21 '05 #1
1 3739
"Tony" <G@G.it> schrieb
Hello,

I a byte array and i put to remote class (to blocks)

I read byte array from a file :
dim fs as FileStream = File.Open(filename, FileMode.Open);
dim data() as byte = new byte(fs.Length){}
fs.Read(data, 0, data.Length)
fs.Close()
You are reading 0 bytes because data.length = 0.
How write to blocks a array to File Stream?

I have Write this code byt not it works :

Dim i As Integer
Dim currentChunk As Integer=0
Dim buffsize As Integer = 4096
Dim fs As FileStream
Dim Data(buffsize) As Byte

fs = New FileStream("C:\fileDestination", FileMode.CreateNew)

Dim bw As BinaryWriter = New BinaryWriter(fs)

For i = 0 To arrayByte.Length / buffsize

You should enable Option Strict to make you aware of programming problems.

Armin
Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Hrvoje Voda | last post by:
How to convert an array byte into string? Hrcko
4
by: Gidi | last post by:
Hi, i have a byte array, and i'm writing it to a file, i want to start a new line, how can i do it? (like WriteLine in StreamWriter) I'm using FileStream: FileStream fs = new...
2
by: Howard Weiss | last post by:
I am reading a file (containing short integers). To read the file, I use the following FileStream *myFile = new FileStream(FileName, FileMode::Open, FileAccess::Read); __int64 myFileSize =...
1
by: Angel Filev | last post by:
Hi everyone, I am trying to store a file as a binary array in an "image" field in SQL Server 2000 database. It works OK except for the ".PDF" files, which I believe get corrupted in the process...
0
by: Dancan | last post by:
Dim UsrSID As Byte() = CType(Child.Properties("objectSID").Value, Byte()) In UsrSID I have array Byte of SID Users. I must Convert in String.... One solution is that to use API...
3
by: David | last post by:
Hi, how to convert a char array(byte) to a string variable? byte buffer; string strTest; /*the blow codes all get type of 'buffer': System.Byte! strTest = buffer.ToString() strTest =...
3
by: Peted | last post by:
In the default state ie somemethod(Byte array); is the byte array passed by method or by reference ? or do you have to use the ref keyword to be able to mod the contents of the orig array...
17
by: =?Utf-8?B?U2hhcm9u?= | last post by:
Hi Gurus, I need to transfer a jagged array of byte by reference to unmanaged function, The unmanaged code should changed the values of the array, and when the unmanaged function returns I need...
1
by: frp | last post by:
I need help. I load text from file into byte, but now I would like to get data(string) from byte. FileStream fs = new FileStream(fileName, FileMode.Open); byte bytes = new byte; for (int j = 0;...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.