convert large files into byte []
-
Hello, how can i convert the large files that exceed 2GB in the binary table, I use byte [] data = File.ReadAllBytes (path); and i have exception. There are another way? thank you very much.
-
Hello, how can i convert the large files that exceed 2GB in the binary table, I use byte [] data = File.ReadAllBytes (path); and i have exception. There are another way? thank you very much.
As previously stated, streaming is probably the only way, unless you want to manually read chunks of the file. .NET has a limit on the maximum size of any one object of 2GB - so no string or array of bytes can exceed this. If you want to read a file bigger than this limit, you have to work in chunks, you cannot read it into any single object in it's entirety. It should be possible to declare an array like type that provides this chunking, and hides the stream or whatever from the main code. In fact there is an example of this on MSDN: http://msdn.microsoft.com/en-us/library/aa288465(v=vs.71).aspx[^] although their method does seem somewhat inefficient, and I would probably cache a block of data if I did it. Depends on how random-access your data is! [edit]Typo: "there" for "their" - OriginalGriff[/edit]
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water