Hello nano2k,
use this one
using (FileStream stream = new FileStream(path, FileMode.Create, FileAccess.Write,
FileShare.Read))
{
stream.Write(bytes, 0, bytes.Length);
}
u can do in blocks, writing to file several times
---
WBR,
Michael Nemtsev [.NET/C# MVP] :: blog:
http://spaces.live.com/laflour
"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo
Hi
For some purposes, I need to create a new binary file and to
allocate
a fixed length for that file on the disk.
I need something like File.Create(string fileName, long
initialSizeInBytes).
Is there a framework/system method to do that or should I create the
file and then fill it until the size is reached?
Thanks
System.IO.File.WriteAllBytes("file.txt", new byte[100]);
Regards,
Mykolahttp://marss.co.ua
n> Hi Mykola
n> Thanks for your response.
n> I'm using .NET Framework 1.1, so this method you suggested is not
n> available in my case.
n> The files I will create are far larger than you suggested in your
n> post. May be hundreds of megs, or even few gigs.
n> What you suggest is that I should create a file, than write the
n> amount
n> of bytes I need. Writing in one shot is not ok. It's not my desire to
n> allocate a huge buffer just to tranfer it to a file.
n> I'd rather write to file successively a reasonable sized buffer until
n> the desired size is reached.
n> This is my approach at the moment, but I thought that there should be
n> a another, more optimum, way to do it