退化File中读取二进制的功能用于修复bug
This commit is contained in:
@@ -201,18 +201,7 @@ namespace Convention
|
|||||||
{
|
{
|
||||||
if (IsFile() == false)
|
if (IsFile() == false)
|
||||||
throw new InvalidOperationException("Target is not a file");
|
throw new InvalidOperationException("Target is not a file");
|
||||||
var file = this.OriginInfo as FileInfo;
|
return File.ReadAllBytes(OriginPath);
|
||||||
const int BlockSize = 1024;
|
|
||||||
long FileSize = file.Length;
|
|
||||||
byte[] result = new byte[FileSize];
|
|
||||||
long offset = 0;
|
|
||||||
using (var fs = file.OpenRead())
|
|
||||||
{
|
|
||||||
fs.ReadAsync(result[(int)(offset)..(int)(offset + BlockSize)], 0, (int)(offset + BlockSize) - (int)(offset));
|
|
||||||
offset += BlockSize;
|
|
||||||
offset = System.Math.Min(offset, FileSize);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<string[]> LoadAsCsv()
|
public List<string[]> LoadAsCsv()
|
||||||
@@ -340,7 +329,8 @@ namespace Convention
|
|||||||
|
|
||||||
public void SaveAsBinary(byte[] data)
|
public void SaveAsBinary(byte[] data)
|
||||||
{
|
{
|
||||||
SaveDataAsBinary(OriginPath, data, (OriginInfo as FileInfo).OpenWrite());
|
using var fs = (OriginInfo as FileInfo).OpenWrite();
|
||||||
|
SaveDataAsBinary(OriginPath, data, fs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SaveAsCsv(List<string[]> csvData)
|
public void SaveAsCsv(List<string[]> csvData)
|
||||||
|
|||||||
Reference in New Issue
Block a user