mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-01 09:47:22 +13:00
Added message box to open file, folder functions to notify user if file or folder is not exist
This commit is contained in:
parent
f4a0cbbf24
commit
aad7c03763
1 changed files with 33 additions and 28 deletions
|
@ -389,18 +389,37 @@ public static string GetProperName(string name)
|
|||
return sb.ToString();
|
||||
}
|
||||
|
||||
public static void OpenFile(string filePath)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(filePath) && File.Exists(filePath))
|
||||
{
|
||||
TaskEx.Run(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
Process.Start(filePath);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DebugHelper.WriteException(e, $"OpenFile({filePath}) failed");
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show(Resources.Helpers_OpenFile_File_not_exist_ + Environment.NewLine + filePath, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
|
||||
public static void OpenFolder(string folderPath)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(folderPath))
|
||||
{
|
||||
if (Directory.Exists(folderPath))
|
||||
if (!string.IsNullOrEmpty(folderPath) && Directory.Exists(folderPath))
|
||||
{
|
||||
Process.Start("explorer.exe", folderPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show(Resources.Helpers_OpenFolder_Folder_not_exist_ + "\r\n" + folderPath, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
MessageBox.Show(Resources.Helpers_OpenFolder_Folder_not_exist_ + Environment.NewLine + folderPath, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -408,7 +427,11 @@ public static void OpenFolderWithFile(string filePath)
|
|||
{
|
||||
if (!string.IsNullOrEmpty(filePath) && File.Exists(filePath))
|
||||
{
|
||||
Process.Start("explorer.exe", string.Format("/select,\"{0}\"", filePath));
|
||||
Process.Start("explorer.exe", $"/select,\"{filePath}\"");
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show(Resources.Helpers_OpenFile_File_not_exist_ + Environment.NewLine + filePath, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -498,24 +521,6 @@ public static bool IsDefaultInstallDir()
|
|||
return Application.ExecutablePath.StartsWith(path);
|
||||
}
|
||||
|
||||
public static void OpenFile(string filepath)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(filepath) && File.Exists(filepath))
|
||||
{
|
||||
TaskEx.Run(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
Process.Start(filepath);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DebugHelper.WriteException(e, string.Format("OpenFile({0}) failed", filepath));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsValidIPAddress(string ip)
|
||||
{
|
||||
if (string.IsNullOrEmpty(ip)) return false;
|
||||
|
|
Loading…
Reference in a new issue