473,327 Members | 2,065 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,327 software developers and data experts.

how to use a buffer to store all the content of bnary file

JC
HI

I want to use a byte array to store all the content of a file. Is there
anyway allow me to do so?

Thx

JC
Nov 21 '05 #1
1 1044
> I want to use a byte array to store all the content of a file. Is there
anyway allow me to do so?


read the contents of a file into a byte array like this:

Dim Filespec as string = "..." ' your file name goes here
Dim fs As IO.FileStream = Nothing
Dim Buffer() As Byte = Nothing
Try
fs = New IO.FileStream(Filespec, IO.FileMode.Open)
ReDim Buffer(CInt(fs.Length))
fs.Read(Buffer, 0, Buffer.Length)
Catch ex As Exception
' whatever you want goes here
Finally
If Not fs Is Nothing Then fs.Close()
End Try
' Buffer() contains the file or your Catch code has done something helpful

Nov 21 '05 #2

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

Similar topics

2
by: Bill Sun | last post by:
Hi, I have a quetion about to refresh the ostringstream buffer: like this. ostringstream buffer; buffer << 245; // then the buffer.str() = "245"; ......
21
by: matvdl | last post by:
I have a system that was originally developed in asp - the pages are saved in SQL (there are over 10,000 pages) and saved to a temp directory in the server when requested by a client. I have...
2
by: vk | last post by:
can you help me out in this .... <IMG style="BORDER-RIGHT: 0px; PADDING-RIGHT: 0px; BORDER-TOP: 0px; PADDING-LEFT: 0px; LEFT: -108px; PADDING-BOTTOM: 0px; MARGIN: 0px; BORDER-LEFT: 0px; WIDTH:...
9
by: Notebooker | last post by:
Hello, I'm an intermediate noob reading-in data from ascii-file using an ifstream object. I have specified a c-style string buffer with size of type size_t and I am specifying to use this...
3
by: jhamb | last post by:
Hello, I want to read a file and to pass the values in a buffer but the values are of different datatype. So I cant put the values in the char type buffer. What to do? I found this but dint...
16
by: Steven D'Aprano | last post by:
On Tue, 09 Sep 2008 14:59:19 -0700, castironpi wrote: You've created a solution to a problem which (probably) only affects a very small number of people, at least judging by your use-cases....
9
by: =?Utf-8?B?U3RldmVuIFRhbmc=?= | last post by:
I want to download pfx from my asp.net server, add the pfx to client's X509Store as a trusted publisher, Is it possible? my func in aspx is like this: void InstallCertification() { try{...
4
by: AAaron123 | last post by:
trying to understand the below shown code. After this is run the browser opens a file-save dialog box for saving the file. I wonder how it knows I want the file saved? But more important, the...
2
by: Ron Hinds | last post by:
I'm getting this in an ASP application on IIS6/W2K3. The page in question is trying to return a XML file approximately 45MB in size. Changing this is not an option. Worked fine on IIS5/W2K. I tried...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.