mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-02 18:26:27 +13:00
Automatically detect MyPictures shell folder path
More shell folders can be supported later
This commit is contained in:
parent
bb3fbf637d
commit
ae025adf46
2 changed files with 18 additions and 2 deletions
|
@ -625,7 +625,7 @@ public static bool BrowseFolder(string title, TextBox tb, string initialDirector
|
|||
|
||||
if (fsd.ShowDialog())
|
||||
{
|
||||
tb.Text = fsd.FileName;
|
||||
tb.Text = GetVariableFolderPath(fsd.FileName);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -633,6 +633,22 @@ public static bool BrowseFolder(string title, TextBox tb, string initialDirector
|
|||
return false;
|
||||
}
|
||||
|
||||
public static string GetVariableFolderPath(string folderPath)
|
||||
{
|
||||
folderPath = folderPath.Replace(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "%UserProfile%");
|
||||
folderPath = folderPath.Replace(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), "%MyPictures%");
|
||||
|
||||
return folderPath;
|
||||
}
|
||||
|
||||
public static string ExpandFolderVariables(string folderPath)
|
||||
{
|
||||
folderPath = folderPath.Replace("%MyPictures%", Environment.GetFolderPath(Environment.SpecialFolder.MyPictures));
|
||||
folderPath = folderPath.Replace("%UserProfile%", Environment.GetFolderPath(Environment.SpecialFolder.UserProfile));
|
||||
|
||||
return Environment.ExpandEnvironmentVariables(folderPath);
|
||||
}
|
||||
|
||||
public static bool WaitWhile(Func<bool> check, int interval, int timeout = -1)
|
||||
{
|
||||
Stopwatch timer = Stopwatch.StartNew();
|
||||
|
|
|
@ -219,7 +219,7 @@ public static string ScreenshotsParentFolder
|
|||
{
|
||||
if (Settings != null && Settings.UseCustomScreenshotsPath && !string.IsNullOrEmpty(Settings.CustomScreenshotsPath))
|
||||
{
|
||||
return Environment.ExpandEnvironmentVariables(Settings.CustomScreenshotsPath);
|
||||
return Helpers.ExpandFolderVariables(Settings.CustomScreenshotsPath);
|
||||
}
|
||||
|
||||
return Path.Combine(PersonalFolder, "Screenshots");
|
||||
|
|
Loading…
Reference in a new issue