private static String GetDisplayName(String originalPath, String fullPath)
        {
            Debug.Assert(originalPath != null);
            Debug.Assert(fullPath != null);

            return(PathHelpers.ShouldReviseDirectoryPathToCurrent(originalPath) ?
                   "." :
                   GetDirName(fullPath));
        }
Exemple #2
0
        private static String GetDisplayName(String originalPath)
        {
            Debug.Assert(originalPath != null);

            // Desktop documents that the path returned by ToString() should be the original path.
            // For SL/Phone we only gave the directory name regardless of what was passed in.
            return(PathHelpers.ShouldReviseDirectoryPathToCurrent(originalPath) ?
                   "." :
                   originalPath);
        }
Exemple #3
0
        public DirectoryInfo(String path)
        {
            if (path == null)
            {
                throw new ArgumentNullException(nameof(path));
            }
            Contract.EndContractBlock();

            OriginalPath = PathHelpers.ShouldReviseDirectoryPathToCurrent(path) ? "." : path;
            FullPath     = Path.GetFullPath(path);
            DisplayPath  = GetDisplayName(OriginalPath);
        }
Exemple #4
0
        private void Init(string originalPath, string fullPath = null, string fileName = null, bool isNormalized = false)
        {
            // Want to throw the original argument name
            OriginalPath = originalPath ?? throw new ArgumentNullException("path");

            fullPath = fullPath ?? originalPath;
            Debug.Assert(!isNormalized || !PathInternal.IsPartiallyQualified(fullPath), "should be fully qualified if normalized");
            fullPath = isNormalized ? fullPath : Path.GetFullPath(fullPath);

            _name = fileName ?? (PathHelpers.IsRoot(fullPath) ?
                                 fullPath :
                                 Path.GetFileName(PathHelpers.TrimEndingDirectorySeparator(fullPath)));

            FullPath    = fullPath;
            DisplayPath = PathHelpers.ShouldReviseDirectoryPathToCurrent(originalPath) ? "." : originalPath;
        }
Exemple #5
0
 public DirectoryInfo(string path)
 {
     Init(originalPath: PathHelpers.ShouldReviseDirectoryPathToCurrent(path) ? "." : path,
          fullPath: Path.GetFullPath(path),
          isNormalized: true);
 }