finally fucking fixed RenameFileWithInvalidChars

This commit is contained in:
Bitl 2021-09-25 13:55:04 -07:00
parent cc6b807c3d
commit f1324f3de9
1 changed files with 16 additions and 7 deletions

View File

@ -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