DownloadManager works!

This commit is contained in:
EntenKoeniq
2022-04-03 02:27:30 +02:00
parent 7c194f38a6
commit 989dcaeb0b
8 changed files with 296 additions and 50 deletions

View File

@ -6,14 +6,16 @@ namespace CoopClient
{
public byte FileID { get; set; }
public Packets.DataFileType FileType { get; set; }
public string FileName { get; set; }
private string FileName = string.Empty;
public long FileLength { get; set; }
private readonly FileStream _stream;
public DownloadManager()
public DownloadManager(string fileName)
{
string downloadFolder = $"scripts\\{Main.MainSettings.LastServerAddress.Replace(":", ".")}";
FileName = fileName;
string downloadFolder = $"scripts\\resources\\{Main.MainSettings.LastServerAddress.Replace(":", ".")}";
if (!Directory.Exists(downloadFolder))
{
Directory.CreateDirectory(downloadFolder);
@ -25,7 +27,7 @@ namespace CoopClient
}
}
_stream = new FileStream(downloadFolder + "\\" + FileName, FileMode.CreateNew);
_stream = new FileStream($"{downloadFolder}\\{fileName}", File.Exists($"{downloadFolder}\\{fileName}") ? FileMode.Truncate : FileMode.CreateNew);
}
/// <summary>