aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller/IO/FileData.cs
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Controller/IO/FileData.cs')
-rw-r--r--MediaBrowser.Controller/IO/FileData.cs16
1 files changed, 16 insertions, 0 deletions
diff --git a/MediaBrowser.Controller/IO/FileData.cs b/MediaBrowser.Controller/IO/FileData.cs
index 21d090a27..b9bc7ea75 100644
--- a/MediaBrowser.Controller/IO/FileData.cs
+++ b/MediaBrowser.Controller/IO/FileData.cs
@@ -121,6 +121,22 @@ namespace MediaBrowser.Controller.IO
[DllImport("kernel32")]
private static extern bool FindClose(IntPtr hFindFile);
+
+ private const char SpaceChar = ' ';
+ private static char[] InvalidFileNameChars = Path.GetInvalidFileNameChars();
+
+ /// <summary>
+ /// Takes a filename and removes invalid characters
+ /// </summary>
+ public static string GetValidFilename(string filename)
+ {
+ foreach (char c in InvalidFileNameChars)
+ {
+ filename = filename.Replace(c, SpaceChar);
+ }
+
+ return filename;
+ }
}
[StructLayout(LayoutKind.Sequential)]