finally fucking fixed RenameFileWithInvalidChars
This commit is contained in:
parent
cc6b807c3d
commit
f1324f3de9
|
|
@ -1901,15 +1901,24 @@ public class GlobalFuncs
|
||||||
|
|
||||||
public static void RenameFileWithInvalidChars(string path)
|
public static void RenameFileWithInvalidChars(string path)
|
||||||
{
|
{
|
||||||
if (!FileHasInvalidChars(path))
|
try
|
||||||
return;
|
{
|
||||||
|
if (!FileHasInvalidChars(path))
|
||||||
|
return;
|
||||||
|
|
||||||
string pathWithoutFilename = Path.GetDirectoryName(path);
|
string pathWithoutFilename = Path.GetDirectoryName(path);
|
||||||
string fileName = Path.GetFileName(path);
|
string fileName = Path.GetFileName(path);
|
||||||
fileName = Regex.Replace(fileName, @"[^\w-.'_!()& ]", "");
|
fileName = Regex.Replace(fileName, @"[^\w-.'_!()& ]", "");
|
||||||
string finalPath = pathWithoutFilename + "\\" + fileName;
|
string finalPath = pathWithoutFilename + "\\" + fileName;
|
||||||
|
|
||||||
FixedFileMove(path, finalPath, false);
|
FixedFileMove(path, finalPath, File.Exists(finalPath));
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
#if LAUNCHER || CMD || URI
|
||||||
|
LogExceptions(ex);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if LAUNCHER || CMD || URI
|
#if LAUNCHER || CMD || URI
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue