Re: Opening large files for small amounts of data
- From: "Randy Birch" <rgb_removethis@xxxxxxxx>
- Date: Fri, 23 Dec 2005 21:08:43 -0500
: When I open a file in VB, what really happens? What I mean is that I
: may have a file on a remote server, but still inside of our network,
: that can be over 1 GB in size. If I just need to open it to append a
: small amount of data to it, how much traffic over the network really
: occurs?
AFAIK, it just acquires access to the file with no significant traffic. It
doesn't haul down the file, for example.
: How about for reading a couple of lines from that file (say the last 2
: lines)?
If you're opening in Binary mode and using Seek to move the file pointer to
a specific spot, or using Random Access mode with fixed-size UDTs, you can
access any point or record in the file in random order, forwards or
backwards. If the file is opened for Append, however, the only way to move
to the last couple of lines for reading is to read each line starting from
the beginning. You could, I suppose, try mixing a Seek call after the file
was opened for append but you'd have to handle tracking where the data you
want to read is located.
: Are there things I can do to make sure that I can get the fastest
: access times?
All are fast for access; any sequential file method (input/output/append)
will require reading from the start of the file to reach any point later in
the file (for reading). Naturally append itself automatically expects to add
new data to the end. So if you can bypass any reading of the file's current
data, you're overhead is just that needed to pass the data to be written to
the file.
: How does a computer actually "Open" a file, and how much data is sent
: at that time?
It acquires a handle to the file from the operating system. Probably no more
than a few bytes are involved in the actual work in doing this. The largest
overhead is hauling the file data down to the client system (i.e. a file
read), or re-writing an entire file at the destination (re-writing from
memory, as opposed to copying the file itself).
--
Randy Birch
MS MVP Visual Basic
http://vbnet.mvps.org/
----------------------------------------------------------------------------
Read. Decide. Sign the petition to Microsoft.
http://classicvb.org/petition/
----------------------------------------------------------------------------
.
- Follow-Ups:
- References:
- Prev by Date: Re: How do I define multiple treeview node styles at the same level
- Next by Date: Re: How do I define multiple treeview node styles at the same level
- Previous by thread: Opening large files for small amounts of data
- Next by thread: Re: Opening large files for small amounts of data
- Index(es):
Relevant Pages
|