Fix important bug

- Fixed a bug that caused the content of the file to be sent as the filename
This commit is contained in:
Stone_Red
2022-02-28 20:28:05 +01:00
parent 9675361695
commit a90af811c1
2 changed files with 85 additions and 80 deletions
@@ -167,6 +167,9 @@ namespace HyperbolicDownloaderApi.Networking
FileInfo fileInfo = new FileInfo(hyperFileInfo.FilePath);
bytesToSend = Encoding.ASCII.GetBytes($"{fileInfo.Length}/{Path.GetFileName(hyperFileInfo.FilePath)}");
Array.Resize(ref bytesToSend, 1000);
await nwStream.WriteAsync(bytesToSend);
foreach (byte[]? chunk in FileCompressor.ReadChunks(hyperFileInfo.FilePath, 64000))
@@ -182,12 +185,15 @@ namespace HyperbolicDownloaderApi.Networking
bytesToSend = Encoding.ASCII.GetBytes("File not found!");
await nwStream.WriteAsync(bytesToSend);
}
client.Close();
}
catch (Exception ex)
{
Debug.WriteLine(ex);
}
finally
{
client.Close();
}
}
public void StopListening()