From 97bc7ec37891a4e2ea924d565c8ec98cc53601a8 Mon Sep 17 00:00:00 2001 From: LukePulverenti Luke Pulverenti luke pulverenti Date: Tue, 28 Aug 2012 08:39:23 -0400 Subject: Added error handling for both IBN and providers --- MediaBrowser.Controller/IO/FileData.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'MediaBrowser.Controller/IO/FileData.cs') 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(); + + /// + /// Takes a filename and removes invalid characters + /// + public static string GetValidFilename(string filename) + { + foreach (char c in InvalidFileNameChars) + { + filename = filename.Replace(c, SpaceChar); + } + + return filename; + } } [StructLayout(LayoutKind.Sequential)] -- cgit v1.2.3