473,799 Members | 3,159 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1061
> 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(F ilespec, IO.FileMode.Ope n)
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
4044
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
2970
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 updated this system and changed the pages that are saved to the server as aspx - everything works fine and pages can be served - but Its not impossible for a single client to request 100 plus pages in one session - as each page is requested it is...
2
1338
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: 256px; PADDING-TOP: 0px; BORDER-BOTTOM: 0px; POSITION: absolute; TOP: -175px; HEIGHT: 256px" src="http://mt0.google.com/mt?n=404&v=ap.14&x=1314&y=3174&zoom=4" unselectable="on" galleryImg="no" coordX="0" coordY="0" priority="0"> i need to parse...
9
8807
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 buffer size as the number of characters to read in using the function read(). The issue I am having is read() expects that the value for the number of characters to read-in will be of type std::streamsize, which is apparently signed int. My buffer
3
9463
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 worked for me... void print ( char *Buffer, usigned long bufferSize, int chunkSize ); /*This fn will accept file buffer and the buffer size and the chunk size
16
1618
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. Who has a 4GB XML file, and how much crack did they smoke? Castironpi, what do *you* use this proof-of-concept module for? Don't
9
7273
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{ WebClient web = new WebClient(); string url = "http:/myaspserver/mydir/mykey_2008.pfx"; byte b = web.DownloadData(url);
4
11957
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 dialog box has as the default file name the name of this ashx file. I'd like to make that name more meaningfull but don't know how it gets set. I'm looking for a Response.Write but don't find one. Maybe that why the
2
4215
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 Response.Buffer = False, no joy. So I searched on MSDN and found instructions for increasing the AspBufferingLimit property in the metabase. I increased it to 100MB for that web application, stopped and restarted that web application, still same...
0
9538
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
10470
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10247
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
10214
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
10023
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
9067
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
7561
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
5459
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5583
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.