我正在使用以下代码写入我每次创建新的压缩文件。
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
}
但是,当我运行它时,我收到一个带有“磁盘空间不足”消息的 IOException。但是,我正在写入文件的驱动器上有 19GB 的可用空间。
根据 GZipStream 的文档,它不能用于写入大于 4GB 的文件。但是,到目前为止写入的文件大小只有 250MB。
这是一个例外:
类型:System.IO.IOException 异常消息:磁盘空间不足。
内部异常: StackTrace:在 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 callFromFinalizer) 在 System.IO.FileStream.Dispose(Boolean disposing) 在 System.IO.Stream.Close() 在 System.IO.Compression.DeflateStream.Dispose(Boolean disposing) 在 System.IO.Stream.Close() 在 System .IO.Compression.GZipStream.Dispose(Boolean disposing) at System.IO.Stream.Close() at System.IO.StreamWriter.Dispose(Boolean disposing) at System.IO.StreamWriter.Close()
此外,这不是网络文件。
有什么想法我在这里做错了吗?