aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller/IO/FileData.cs
diff options
context:
space:
mode:
authorLukePulverenti Luke Pulverenti luke pulverenti <LukePulverenti Luke Pulverenti luke.pulverenti@gmail.com>2012-08-28 08:39:23 -0400
committerLukePulverenti Luke Pulverenti luke pulverenti <LukePulverenti Luke Pulverenti luke.pulverenti@gmail.com>2012-08-28 08:39:23 -0400
commit97bc7ec37891a4e2ea924d565c8ec98cc53601a8 (patch)
tree2311c663a3c97a8dcf8c183cc43a6ced97804ae7 /MediaBrowser.Controller/IO/FileData.cs
parent42a28356337db5e4c82b3a898c7dce8836744fcb (diff)
Added error handling for both IBN and providers
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)]