Hi!

I need to save & read some data from a file. The maximum amount of data that might need to be saved/read is about 21 kb and it is almost only text.

How should I achieve this?

I was thinking of using CreateFile,ReadFile,WriteFile etc, but I have never done something like this before. Does anyone have a code snippet that shows how to save/read data from a file? Just getting the whole file is simple, but how can I access a small part of the already loaded file?


/Delight
Posted on 2001-10-12 05:15:27 by Delight
Hi Delight

Reading a file to a memory buffer, modify the memory buffer and write the buffer back to disk is simple.
You say nothing about the structure of your file, so giving any specific advice is difficult.

KetilO
Posted on 2001-10-12 06:35:36 by KetilO
ok.

It's some info to use with ShellExecute. I would like to save a filename (up to 255 bytes), a path (up to 255 bytes),a parameter (255 bytes?) and three numbers (3 bytes?). That's for one file. I would like to save/get that information for up to 28 files.

How should I do this?


Maybe it's easiest to save it as an ini file?

/Delight
Posted on 2001-10-12 07:02:21 by Delight
Hi Delight

Using a ini file would be the easiest to do, random access is probably the best, but you would have to write the file system handling yourself.

KetilO
Posted on 2001-10-12 07:34:52 by KetilO
Hi Delight,
for the reading part you could easily use Memory Mapped Files. I'm not sure they also work well in writing.

Daniel
Posted on 2001-10-12 12:06:26 by dguzz
memory mapped files work fine in writing... but only when you keep
a static filesize.
Posted on 2001-10-12 12:08:37 by f0dder