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