mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-30 01:07:21 +13:00
fixed #72: Show warning if file access fail and not try to write if file content is same
This commit is contained in:
parent
8c149a2f56
commit
02be5288e1
1 changed files with 26 additions and 3 deletions
|
@ -369,10 +369,33 @@ public static string ReadPersonalPathConfig()
|
|||
|
||||
public static void WritePersonalPathConfig(string path)
|
||||
{
|
||||
// If path is empty and config file is not exist then don't create it
|
||||
if (!string.IsNullOrEmpty(path) || File.Exists(PersonalPathConfig))
|
||||
if (path == null)
|
||||
{
|
||||
File.WriteAllText(PersonalPathConfig, path ?? string.Empty, Encoding.UTF8);
|
||||
path = string.Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
path = path.Trim();
|
||||
}
|
||||
|
||||
bool isDefaultPath = string.IsNullOrEmpty(path) && !File.Exists(PersonalPathConfig);
|
||||
|
||||
if (!isDefaultPath)
|
||||
{
|
||||
string currentPath = ReadPersonalPathConfig();
|
||||
|
||||
if (!path.Equals(currentPath, StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
try
|
||||
{
|
||||
File.WriteAllText(PersonalPathConfig, path, Encoding.UTF8);
|
||||
}
|
||||
catch (UnauthorizedAccessException)
|
||||
{
|
||||
MessageBox.Show("Can't access to \"" + PersonalPathConfig + "\" file.\r\nPlease run ShareX as administrator to change personal folder path.", "ShareX",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue