Skip to content

Commit

Permalink
[Core] Refactored FileEntity
Browse files Browse the repository at this point in the history
  • Loading branch information
Linwenxuan authored and Linwenxuan committed Oct 29, 2023
1 parent 958a033 commit 5dac7a5
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions Lagrange.Core/Message/Entity/FileEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,13 @@ public FileEntity()
{
FileName = "";
FileMd5 = Array.Empty<byte>();

}

public FileEntity(string path)
{
using var stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);
using var md5 = MD5.Create();
FileMd5 = md5.ComputeHash(stream);
FileSize = stream.Length;
FileStream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);
FileMd5 = FileStream.Md5().UnHex();
FileSize = FileStream.Length;
FileName = Path.GetFileName(path);
}

Expand Down

0 comments on commit 5dac7a5

Please sign in to comment.