using System; using System.IO; using Ringtoets.Piping.IO.Properties; namespace Ringtoets.Piping.IO { /// /// Class with reusable File related utility methods. /// static internal class FileUtils { /// /// Validates the file path. /// /// The file path to be validated. /// is invalid. public static void ValidateFilePath(string path) { if (String.IsNullOrWhiteSpace(path)) { throw new ArgumentException(Resources.Error_PathMustBeSpecified); } string name; try { name = Path.GetFileName(path); } catch (ArgumentException e) { throw new ArgumentException(String.Format(Resources.Error_PathCannotContainCharacters_0_, String.Join(", ", Path.GetInvalidFileNameChars())), e); } if (String.Empty == name) { throw new ArgumentException(Resources.Error_PathMustNotPointToFolder); } } } }