You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
889B

  1. using SIE.IVSDK.Services;
  2. using System;
  3. using System.IO;
  4. using System.Text.RegularExpressions;
  5. namespace SIE.VSDK.Services
  6. {
  7. public class PathService : IPathService
  8. {
  9. public bool IsValidPath(string path, bool allowRelativePaths = false)
  10. {
  11. bool isValid = true;
  12. try
  13. {
  14. string fullPath = Path.GetFullPath(path);
  15. if (allowRelativePaths)
  16. {
  17. isValid = Path.IsPathRooted(path);
  18. }
  19. else
  20. {
  21. string root = Path.GetPathRoot(path);
  22. isValid = string.IsNullOrEmpty(root.Trim(new char[] { '\\', '/' })) == false;
  23. }
  24. }
  25. catch (Exception ex)
  26. {
  27. isValid = false;
  28. }
  29. return isValid;
  30. }
  31. }
  32. }