473,666 Members | 2,678 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(filen ame, 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.Create New)

Dim bw As BinaryWriter = New BinaryWriter(fs )

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

bw.Close()
Nov 21 '05 #1
1 3746
"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(filen ame, 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.Create New)

Dim bw As BinaryWriter = New BinaryWriter(fs )

For i = 0 To arrayByte.Lengt h / 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
1342
by: Hrvoje Voda | last post by:
How to convert an array byte into string? Hrcko
4
16922
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 FileStream(file_name,FileMode.Create ); Aftrer i used fs.Write(Byte b1); i want to start a new line in my file and then write my second array Byte
2
2331
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 = myFile->get_Length(); Byte myFileData; myFile1Data = new Byte;
1
5754
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 of reading a stream to a byte array. Uploading and downloading seems to work fine, but "Acrobat" pop ups "The file is damaged and could not be repaired" error. Is there any way I can make this to work.
0
4208
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 ConvertSidToStringSid(ADVAPI32.DLL) but this functionally not implemented into Windows 9x....(i have tried also install Extension for Active directory for Win9x)
3
3647
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 = System.Convert.ToString(buffer)
3
16733
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 from inside the method ?
17
7239
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 to show the array data to the end user. Can I do that? How?
1
1857
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; j < bytes.Length; j++) { bytes = (byte)fs.ReadByte(); } fs.Close();
0
8348
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8779
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8549
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8636
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7376
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6187
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5660
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2765
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1761
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.