Fix file length accumulation

pull/582/head
NextTurn 2018-11-26 00:00:00 -09:00
parent 6c966cecc9
commit 37aee80a8a
No known key found for this signature in database
GPG Key ID: 17A0D50ADDE1A0C4
1 changed files with 3 additions and 2 deletions

View File

@ -4,6 +4,7 @@ using System.Diagnostics;
using System.IO.Compression; using System.IO.Compression;
#endif #endif
using System.IO; using System.IO;
using System.Text;
using System.Threading; using System.Threading;
#if !VNEXT #if !VNEXT
using ICSharpCode.SharpZipLib.Zip; using ICSharpCode.SharpZipLib.Zip;
@ -264,7 +265,7 @@ namespace WinSW
string? line; string? line;
while ((line = reader.ReadLine()) != null) while ((line = reader.ReadLine()) != null)
{ {
int lengthToWrite = (line.Length + Environment.NewLine.Length) * sizeof(char); int lengthToWrite = Encoding.UTF8.GetByteCount(line) + 2; // CRLF
if (fileLength + lengthToWrite > this.SizeTheshold) if (fileLength + lengthToWrite > this.SizeTheshold)
{ {
writer.Dispose(); writer.Dispose();
@ -437,7 +438,7 @@ namespace WinSW
{ {
lock (fileLock) lock (fileLock)
{ {
int lengthToWrite = (line.Length + Environment.NewLine.Length) * sizeof(char); int lengthToWrite = Encoding.UTF8.GetByteCount(line) + 2; // CRLF
if (fileLength + lengthToWrite > this.SizeTheshold) if (fileLength + lengthToWrite > this.SizeTheshold)
{ {
try try