-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathPathHelper.cs
More file actions
44 lines (39 loc) · 1.56 KB
/
PathHelper.cs
File metadata and controls
44 lines (39 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//*****************************************************************************
//* Code Factory SDK
//* Copyright (c) 2020 CodeFactory, LLC
//*****************************************************************************
using System.IO;
using System.Linq;
namespace CodeFactory.VisualStudio
{
/// <summary>
/// Static helper class that contains functions to support path management with visual studio.
/// </summary>
public static class PathHelper
{
/// <summary>
/// Contains array of invalid characters allowed in a path.
/// </summary>
private static readonly char[] _invalidPathNameCharacter = Path.GetInvalidPathChars();
/// <summary>
/// The invalid characters not allowed in a path name.
/// </summary>
public static string InvalidPathNameCharacters => new string(_invalidPathNameCharacter);
/// <summary>
/// Provided file name is checked to determine if it has
/// </summary>
/// <param name="path">The path to be evaluated.</param>
/// <returns>True if invalid characters exists or false if the file does not have invalid characters.</returns>
public static bool ContainsInvalidPathNameCharacter(string path)
{
bool result = false;
if (string.IsNullOrEmpty(path)) return false;
foreach (var invalidCharacter in _invalidPathNameCharacter)
{
result = path.Contains(invalidCharacter);
if (result) break;
}
return result;
}
}
}