{
if (path != null)
{
- PathInternal.CheckInvalidPathChars(path);
-
int length = path.Length;
if ((length >= 1 && PathInternal.IsDirectorySeparator(path[0])) ||
(length >= 2 && PathInternal.IsValidDriveChar(path[0]) && path[1] == PathInternal.VolumeSeparatorChar))
if (PathInternal.IsEffectivelyEmpty(path))
throw new ArgumentException(SR.Arg_PathEmpty, nameof(path));
- PathInternal.CheckInvalidPathChars(path);
-
// Need to return the normalized directory separator
path = PathInternal.NormalizeDirectorySeparators(path);
{
if (path != null)
{
- PathInternal.CheckInvalidPathChars(path);
-
string s = path;
for (int i = path.Length - 1; i >= 0; i--)
{
if (PathInternal.IsEffectivelyEmpty(path))
throw new ArgumentException(SR.Arg_PathEmpty, nameof(path));
- PathInternal.CheckInvalidPathChars(path);
path = PathInternal.NormalizeDirectorySeparators(path);
int root = PathInternal.GetRootLength(path);
if (path == null)
return null;
- PathInternal.CheckInvalidPathChars(path);
int length = path.Length;
for (int i = length - 1; i >= 0; i--)
{
{
if (path != null)
{
- PathInternal.CheckInvalidPathChars(path);
-
for (int i = path.Length - 1; i >= 0; i--)
{
char ch = path[i];
if (path1 == null || path2 == null)
throw new ArgumentNullException((path1 == null) ? nameof(path1) : nameof(path2));
- PathInternal.CheckInvalidPathChars(path1);
- PathInternal.CheckInvalidPathChars(path2);
-
return CombineNoChecks(path1, path2);
}
if (path1 == null || path2 == null || path3 == null)
throw new ArgumentNullException((path1 == null) ? nameof(path1) : (path2 == null) ? nameof(path2) : nameof(path3));
- PathInternal.CheckInvalidPathChars(path1);
- PathInternal.CheckInvalidPathChars(path2);
- PathInternal.CheckInvalidPathChars(path3);
-
return CombineNoChecks(path1, path2, path3);
}
if (path1 == null || path2 == null || path3 == null || path4 == null)
throw new ArgumentNullException((path1 == null) ? nameof(path1) : (path2 == null) ? nameof(path2) : (path3 == null) ? nameof(path3) : nameof(path4));
- PathInternal.CheckInvalidPathChars(path1);
- PathInternal.CheckInvalidPathChars(path2);
- PathInternal.CheckInvalidPathChars(path3);
- PathInternal.CheckInvalidPathChars(path4);
-
return CombineNoChecks(path1, path2, path3, path4);
}
continue;
}
- PathInternal.CheckInvalidPathChars(paths[i]);
-
if (IsPathRooted(paths[i]))
{
firstComponent = i;
internal static partial class PathInternal
{
/// <summary>
- /// Checks for invalid path characters in the given path.
- /// </summary>
- /// <exception cref="System.ArgumentNullException">Thrown if the path is null.</exception>
- /// <exception cref="System.ArgumentException">Thrown if the path has invalid characters.</exception>
- /// <param name="path">The path to check for invalid characters.</param>
- internal static void CheckInvalidPathChars(string path)
- {
- if (path == null)
- throw new ArgumentNullException(nameof(path));
-
- if (HasIllegalCharacters(path))
- throw new ArgumentException(SR.Argument_InvalidPathChars, nameof(path));
- }
-
- /// <summary>
/// Returns the start index of the filename
/// in the given path, or 0 if no directory
/// or volume separator is found.
internal static int FindFileNameIndex(string path)
{
Debug.Assert(path != null);
- CheckInvalidPathChars(path);
for (int i = path.Length - 1; i >= 0; i--)
{