コード例 #1
0
 /// <summary>
 /// Ensures that the specified path does not end in a directory separator.
 /// </summary>
 /// <returns>The path with an appended directory separator if necessary.</returns>
 /// <exception cref="System.ArgumentNullException">Thrown if path is null.</exception>
 public static string RemoveTrailingSeparators(string path)
 {
     if (path == null)
     {
         throw new ArgumentNullException(nameof(path));
     }
     if (Paths.EndsInDirectorySeparator(path))
     {
         return(path.TrimEnd(Paths.directorySeparatorCharacters));
     }
     else
     {
         return(path);
     }
 }
コード例 #2
0
 /// <summary>
 /// Ensures that the specified path ends in a directory separator.
 /// </summary>
 /// <returns>The path with an appended directory separator if necessary.</returns>
 /// <exception cref="System.ArgumentNullException">Thrown if path is null.</exception>
 public static string AddTrailingSeparator(string path)
 {
     if (path == null)
     {
         throw new ArgumentNullException(nameof(path));
     }
     if (Paths.EndsInDirectorySeparator(path))
     {
         return(path);
     }
     else
     {
         return(path + DirectorySeparator);
     }
 }