Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

async file write

Status
Not open for further replies.

mander23

MIS
Jan 30, 2005
28
US
I would like to be able to async file write. I would like to open a file and I would get the length like so.
fs.Read(buffer, 0, buffer.Length)

then I would like to open 2 filestream and write at the same time so it doesn't take as long. For example if the total length of the file is 100. I would split up and write 0-50 on one filestream and 51-100 on the second filestream, only writing them at the same time. Is this possible? Thank you.
 
No. You would have the file open with stream 1 and you would get a write error on the second stream. If for some reason you didn't get a file write error, your data would be interwoven.

you would get something like:
line 1
line 2
line 51
line 3
line 52
...

You could overlap writing out 2 separate text files.

-Sometimes the answer to your question is the hack that works
 
What do you mean by overlap. THe file I have is a tif file. Is there someway I can do it with that.
 
A filestream is a file stream. the bytes you dump out are irrelevant. Whether your pic comes out jumbled or your homework gets saved out of order...

if you were able to pass a reference to an open file stream, or reference the open file stream from a thread you still run into this problem:

Rather than asking kid 1 to tell you the first half of the story then asking kid 2 to tell you the second half,
you have kid 1 tell you the first line of the first half of the story, then kid 2 tells you the first line of the second half of the story. it won't make sense when it's done.


-Sometimes the answer to your question is the hack that works
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top