I am using the following code to write to a compressed file that I create new everytime.
using (FileStream fs = File.Open(sortOrderFileName, FileMode.Create,FileAccess.Write, FileShare.ReadWrite))
using (System.IO.Compression.GZipStream gzip = new System.IO.Compression.GZipStream(fs, System.IO.Compression.CompressionMode.Compress))
using (StreamWriter sw = new StreamWriter(gzip))
{
// use the streamwriter sw to write to the stream
}
However, when I run this, I am getting an IOException with the message "Out of disk space". However, there is 19GB of space available on the drive on which I am writing the file.
According to the docs for GZipStream, it cannot be used to write a file greater than 4GB. However, the file written till now is only 250MB in size.
Here is the exception:
Type: System.IO.IOException Exception Msg: There is not enough space on the disk.
Inner Exception: StackTrace: at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.WriteCore(Byte[] buffer, Int32 offset, Int32 count) at System.IO.FileStream.FlushWrite(Boolean calledFromFinalizer) at System.IO.FileStream.Dispose(Boolean disposing) at System.IO.Stream.Close() at System.IO.Compression.DeflateStream.Dispose(Boolean disposing) at System.IO.Stream.Close() at System.IO.Compression.GZipStream.Dispose(Boolean disposing) at System.IO.Stream.Close() at System.IO.StreamWriter.Dispose(Boolean disposing) at System.IO.StreamWriter.Close()
Also, this is not a network file.
Any ideas what I am doing wrong here?