programming files of size larger than 2 GB using C

2019-07-19 02:46发布

问题:

How to write large content to disk dynamically using c sharp. any advice or reference is appreciated.

Iam trying to create a file(custom format and extension)and writing to it. The User will upload a file and its contents are converted to byte stream and is written to the file(filename.hd).The indexing of the uploaded files is done in another file(filename.hi).

This works fine for me when the "filename.hd" file size is 2 GB when it exceeds 2GB it is not allowing me to add the content.This is my problem.

After googling i found that the FAT 32 windows based system (most of the versions) only support 2GB of file size.Is there any solution for me to handle this situation.Please let me know.

Thanks in advance sree

回答1:

Use another filesystem (e.g. NTFS) ?



回答2:

Use StreamWriter for writing to disk. StringBuilder is recommended to create the string, since when using 'string' appending two strings really creates a new string, which hurts preformance.



回答3:

Okay you will have some restrictions that are not code related: File system - FAT and FAT32 will restrict you. Whether the system is 16, 32 or 64 bit will place restrictions on you.