Fixed invalid filenames

This commit is contained in:
Serraniel 2017-10-12 20:15:46 +02:00
parent 5c45aad049
commit 5ea5abfdfd

View file

@ -229,8 +229,7 @@ namespace DML.AppCore.Classes
var socketTextChannel = message.Channel as SocketTextChannel;
if (socketTextChannel != null)
{
serverName = socketTextChannel.Guild.Name.Replace(":", "").Replace("/", "")
.Replace("\\", "").Replace("|", "");
serverName = socketTextChannel.Guild.Name;
}
fileName =
@ -240,6 +239,8 @@ namespace DML.AppCore.Classes
.Replace("%name%", a.Filename)
.Replace("%id%", a.Id.ToString());
fileName = Path.GetInvalidFileNameChars().Aggregate(fileName, (current, c) => current.Replace(c, ' '));
if (extensionRequired)
fileName += Path.GetExtension(a.Filename);