Fix FileName

This commit is contained in:
Perfare
2017-03-31 16:41:36 +08:00
parent 60cc81b2dd
commit 86843f81da
2 changed files with 10 additions and 2 deletions

View File

@ -365,6 +365,7 @@ namespace Unity_Studio
{
asset.Text += " #" + asset.uniqueID;
}
asset.Text = FixFileName(asset.Text);
assetsFile.exportableAssets.Add(asset);
}
ProgressBarPerformStep();
@ -1853,5 +1854,11 @@ namespace Unity_Studio
Directory.CreateDirectory(Path.GetDirectoryName(filename));
return false;
}
private static string FixFileName(string str)
{
if (str.Length >= 260) return Path.GetRandomFileName();
return Path.GetInvalidFileNameChars().Aggregate(str, (current, c) => current.Replace(c, '_'));
}
}
}