tags:

views:

711

answers:

3

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

A: 

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.

Clangon
-1 This answer has nothing to do with the question. Did the question change...?
emddudley
yes the question changed dramaticly...
Clangon
+5  A: 

Use another filesystem (e.g. NTFS) ?

marklam
A: 

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.

ChrisBD
hi Chris,Do you mean that we cant create a file larger than 2GB?
Charan
No. If you are using FAT32 then the maximum file size is actually 4Gb (assuming that you have 4Gb space free), FAT16 is 2Gb. Are you certain that you are using bytes and not chars?An alternative is to extend your written data into another file and place that file name and index in your index file. Then link across the two using whatever method you currently use to obtain data from your data file.
ChrisBD
You mean to say i do not have an other option other than creating another file if one is full right?
Charan
From what you've told us so far, yes. Although I am unsure as to why you are unable to to write a 4Gb file, which I thought was the limit for FAT32.If you could place a sample of your code above or the result of a try catch block and return information from the file write operation then we could help you further.
ChrisBD