mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-02 18:26:27 +13:00
fixed #1735: Save temporary files to "Temp/ShareX" folder and on ShareX startup clean this folder
This commit is contained in:
parent
bcbaa0e767
commit
e6563f9c3e
2 changed files with 32 additions and 3 deletions
|
@ -213,7 +213,10 @@ private void StartDownload()
|
|||
Status = DownloaderFormStatus.DownloadStarted;
|
||||
btnAction.Text = Resources.DownloaderForm_StartDownload_Cancel;
|
||||
|
||||
SavePath = Path.Combine(Path.GetTempPath(), Filename);
|
||||
string folderPath = Path.Combine(Path.GetTempPath(), "ShareX");
|
||||
Helpers.CreateDirectoryFromDirectoryPath(folderPath);
|
||||
SavePath = Path.Combine(folderPath, Filename);
|
||||
|
||||
fileStream = new FileStream(SavePath, FileMode.Create, FileAccess.Write, FileShare.Read);
|
||||
fileDownloader = new FileDownloader(URL, fileStream, Proxy, AcceptHeader);
|
||||
fileDownloader.FileSizeReceived += (v1, v2) => ChangeProgress();
|
||||
|
|
|
@ -312,9 +312,8 @@ private static void Run()
|
|||
IgnoreHotkeyWarning = CLI.IsCommandExist("NoHotkeys");
|
||||
|
||||
CheckPuushMode();
|
||||
|
||||
DebugWriteFlags();
|
||||
|
||||
CleanTempFiles();
|
||||
LoadProgramSettings();
|
||||
|
||||
UploaderSettingsResetEvent = new ManualResetEvent(false);
|
||||
|
@ -665,5 +664,32 @@ private static void DebugWriteFlags()
|
|||
DebugHelper.WriteLine("Flags: " + output);
|
||||
}
|
||||
}
|
||||
|
||||
private static void CleanTempFiles()
|
||||
{
|
||||
new Thread(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
string tempFolder = Path.GetTempPath();
|
||||
|
||||
if (!string.IsNullOrEmpty(tempFolder))
|
||||
{
|
||||
string folderPath = Path.Combine(tempFolder, "ShareX");
|
||||
|
||||
if (Directory.Exists(folderPath))
|
||||
{
|
||||
Directory.Delete(folderPath, true);
|
||||
|
||||
DebugHelper.WriteLine("Temp files cleaned: " + folderPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DebugHelper.WriteException(e);
|
||||
}
|
||||
}).Start();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue