开发者

The maximum size for file that can be read in .net

Wha开发者_高级运维t's the maximum size of file that can be read in .net Framework ?

It's the long(Int64) max because it's the type of the offset in the Seek method in all reader ?


I believe the answer is "undefined" by the language specification.

The seek offset is based of an origin, so you can seek a file larger long max. You just can't seek from the file start. Also, the file object does not have to support seek to be read. There's more info in the FileStream.Seek Documentation

Maybe someone else knows better, but I don't believe there's a maximum file size defined. You'll be constrained by what you do with the data read from the filesystem ( e.g. running out of memory to store it, etc. )


It is only constrained by the file system. Seek() isn't a required function, C/C++ programmers have dealt with their fseek()'s limit of 2 gigabytes for a long time. Lots of file access is sequential. The .NET version is however going to work without trouble for a while though, the current Windows file system (NTFS version 6) limits the file size to 17,592,185,978,880 bytes, well south of 2^63 - 1.


The theoretical maximum (not taking the file system limitations into account) is Int64.MaxValue, as you had guessed. I'm not sure what happens if you read a file longer than that, but it seems very unlikely ;)


That would be my guess, but there are other constraints, such as the file size imposed by the file system. On NTFS it is 2 Terabytes, but on FAT32 it is 4GB minus 2 Bytes, for example.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜