Esempio n. 1
0
 public static string ValidFilename(string filename)
 {
     char[] array   = Useful.Windows1252ToASCII(filename, '_').ToCharArray();
     char[] invalid = Path.GetInvalidFileNameChars();
     for (int i = 0; i < array.Length; i++)
     {
         foreach (char c in invalid)
         {
             if (array[i] == c)
             {
                 array[i] = '_';
             }
         }
     }
     return(new string(array));
 }
Esempio n. 2
0
        protected string GetValidOutputPath(string outputPath, string shortName)
        {
            if (!Directory.Exists(outputPath))
            {
                throw new Exception("The output path \"" + outputPath + "\" not exist.");
            }

            if (shortName.Length == 0)
            {
                throw new Exception("The short name is empty.");
            }

            char[] array   = Useful.Windows1252ToASCII(shortName, '_').ToCharArray();
            char[] invalid = Path.GetInvalidFileNameChars();
            for (int i = 0; i < array.Length; i++)
            {
                foreach (char c in invalid)
                {
                    if (array[i] == c)
                    {
                        array[i] = '_';
                    }
                }
            }
            string folderName = new string(array);

            StringBuilder strBuilder = new StringBuilder();

            strBuilder.Append(outputPath);
            strBuilder.Append("\\");
            strBuilder.Append(folderName);
            strBuilder.Append(" [");
            strBuilder.Append(TitleId);
            strBuilder.Append("]");
            return(strBuilder.ToString());
        }