tags:

views:

106

answers:

4

What'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 ?

A: 

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.

Robert Harvey
I always thought the file size limit on FAT32 was 2^32 - 1 bytes? Do you have a source for the 2Gb limit?
Russ Cam
Fixed...http://www.ntfs.com/ntfs_vs_fat.htm
Robert Harvey
A: 

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 ;)

Thomas Levesque
Only 8388608 tebibyte... a modest limit ;)
Skurmedel
+1  A: 

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.

Hans Passant
+6  A: 

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. )

kervin