Re: FileStream questions
- From: "John Rogers" <johnrogers2345@xxxxxxx>
- Date: Wed, 5 Mar 2008 20:17:05 -0600
Thanks for the tip Pete, I did a bit of searching and now I have it working.
My problem was not reading the bool value of what I was putting in,
so everything looked wrong when the values came out.
When using the same scenario using BinaryWriter and FileStream, do you
know how to click on a treenode and have many records for that node
display in a listview? I can't even begin to think of how to do that.
know how to get one record to display, but if you have maybe 20
records attached to one node, I just don't know.
John
"Peter Duniho" <NpOeStPeAdM@xxxxxxxxxxxxxxxx> wrote in message
news:op.t7kh91n78jd0ej@xxxxxxxxxxxxxxxxxxxxxxx
On Wed, 05 Mar 2008 14:27:07 -0800, John <johnrogers2345@xxxxxxx> wrote:
[...]
1. How do you read the file from beginning to end, reading from the first
record until there is no more records?
You're writing strings, so you need to use BinaryReader.ReadString().
Looking at the docs, it appears to me that the ReadString() method will
throw an exception once you've reached the end of the stream.
2. When saving to the file, do you always have to replace the entire
file,
or can you just update the information whenever any single item has
changed?
You do not have to replace the entire file. However, that's not to say
that it'd be easy to replace individual chunks of data within the file.
The file is still a stream of bytes, even if you wrap the FileStream that
opened it with a BinaryWriter. You can replace bytes, but there's no
facility to insert or delete bytes. So unless you're trying to replace a
section of the file with an identical length section, you need to rewrite
all of the data after that section, at a minimum, to adjust for the change
in size of the chunk you're modifying.
It's not the sort of thing you'd want to do over and over for large files.
Pete
.
- Follow-Ups:
- Re: FileStream questions
- From: Peter Duniho
- Re: FileStream questions
- References:
- FileStream questions
- From: John
- Re: FileStream questions
- From: Peter Duniho
- FileStream questions
- Prev by Date: Re: EventArgs and derived classes
- Next by Date: app.config files..
- Previous by thread: Re: FileStream questions
- Next by thread: Re: FileStream questions
- Index(es):
Relevant Pages
|