次のコードを使用して、毎回新しく作成する圧縮ファイルに書き込みます。
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) で System.IO.FileStream.WriteCore(Byte[] バッファー、Int32 オフセット、Int32 カウント) で System.IO.FileStream.FlushWrite(Boolean) calledFromFinalizer) で System.IO.FileStream.Dispose(Boolean disposing) で System.IO.Stream.Close() で System.IO.Compression.DeflateStream.Dispose(Boolean disposing) で System.IO.Stream.Close() で System.IO.Stream.Close() .IO.Compression.GZipStream.Dispose(Boolean disposing) at System.IO.Stream.Close() at System.IO.StreamWriter.Dispose(Boolean disposing) at System.IO.StreamWriter.Close()
また、これはネットワーク ファイルではありません。
ここで私が間違っていることはありますか?