public DirectoryInfo CreateSubdirectory(String path)
        {
            if (path == null)
            {
                throw new ArgumentNullException("path");
            }

            String newDirs  = Path.InternalCombine(FullPath, path);
            String fullPath = Path.GetFullPathInternal(newDirs);

            if (0 != String.Compare(FullPath, 0, fullPath, 0, FullPath.Length, StringComparison.OrdinalIgnoreCase))
            {
                String displayPath = __Error.GetDisplayablePath(OriginalPath, false);
                throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Argument_InvalidSubPath"), path, displayPath));
            }

            // Ensure we have permission to create this subdirectory.
            String demandDir = Directory.GetDemandDir(fullPath, true);

            new FileIOPermission(FileIOPermissionAccess.Write, new String[] { demandDir }, false, false).Demand();

            Directory.InternalCreateDirectory(fullPath, path);
            // Check for read permission to directory we hand back by calling this constructor.
            return(new DirectoryInfo(fullPath));
        }
示例#2
0
        [System.Security.SecurityCritical]  // auto-generated
        private DirectoryInfo CreateSubdirectoryHelper(String path, Object directorySecurity)
        {
            Contract.Requires(path != null);

            String newDirs  = Path.InternalCombine(FullPath, path);
            String fullPath = Path.GetFullPathInternal(newDirs);

            if (0 != String.Compare(FullPath, 0, fullPath, 0, FullPath.Length, StringComparison.OrdinalIgnoreCase))
            {
                String displayPath = __Error.GetDisplayablePath(DisplayPath, false);
                throw new ArgumentException(Environment.GetResourceString("Argument_InvalidSubPath", path, displayPath));
            }

            // Ensure we have permission to create this subdirectory.
            String demandDirForCreation = Directory.GetDemandDir(fullPath, true);

#if FEATURE_CORECLR
            FileSecurityState state = new FileSecurityState(FileSecurityStateAccess.Write, OriginalPath, demandDirForCreation);
            state.EnsureState();
#else
            new FileIOPermission(FileIOPermissionAccess.Write, new String[] { demandDirForCreation }, false, false).Demand();
#endif

            Directory.InternalCreateDirectory(fullPath, path, directorySecurity);

            // Check for read permission to directory we hand back by calling this constructor.
            return(new DirectoryInfo(fullPath));
        }
示例#3
0
        /// <include file='doc\DirectoryInfo.uex' path='docs/doc[@for="DirectoryInfo.CreateSubdirectory"]/*' />
        public DirectoryInfo CreateSubdirectory(String path) {
            if (path==null)
                throw new ArgumentNullException("path");
			
            String newDirs = Path.InternalCombine(FullPath, path);
			String fullPath = Path.GetFullPathInternal(newDirs);

			if (0!=String.Compare(FullPath,0,fullPath,0, FullPath.Length,true, CultureInfo.InvariantCulture))
				throw new ArgumentException(String.Format(Environment.GetResourceString("Argument_InvalidSubPath"),path,OriginalPath));
			
            Directory.InternalCreateDirectory(fullPath,path);
			return new DirectoryInfo(fullPath, false);
        }
        private DirectoryInfo CreateSubdirectoryHelper(string path, object directorySecurity)
        {
            string fullPathInternal = Path.GetFullPathInternal(Path.InternalCombine(base.FullPath, path));

            if (string.Compare(base.FullPath, 0, fullPathInternal, 0, base.FullPath.Length, StringComparison.OrdinalIgnoreCase) != 0)
            {
                string displayablePath = __Error.GetDisplayablePath(base.DisplayPath, false);
                throw new ArgumentException(Environment.GetResourceString("Argument_InvalidSubPath", new object[] { path, displayablePath }));
            }
            string demandDir = Directory.GetDemandDir(fullPathInternal, true);

            new FileIOPermission(FileIOPermissionAccess.Write, new string[] { demandDir }, false, false).Demand();
            Directory.InternalCreateDirectory(fullPathInternal, path, directorySecurity);
            return(new DirectoryInfo(fullPathInternal));
        }
示例#5
0
        private DirectoryInfo CreateSubdirectoryHelper(String path, Object directorySecurity)
        {
            Contract.Requires(path != null);

            String newDirs  = Path.Combine(FullPath, path);
            String fullPath = Path.GetFullPath(newDirs);

            if (0 != String.Compare(FullPath, 0, fullPath, 0, FullPath.Length, StringComparison.OrdinalIgnoreCase))
            {
                String displayPath = __Error.GetDisplayablePath(DisplayPath, false);
                throw new ArgumentException(Environment.GetResourceString("Argument_InvalidSubPath", path, displayPath));
            }

            Directory.InternalCreateDirectory(fullPath, path, directorySecurity);

            // Check for read permission to directory we hand back by calling this constructor.
            return(new DirectoryInfo(fullPath));
        }
        //| <include file='doc\DirectoryInfo.uex' path='docs/doc[@for="DirectoryInfo.CreateSubdirectory"]/*' />
        public DirectoryInfo CreateSubdirectory(String path)
        {
            if (path == null)
            {
                throw new ArgumentNullException("path");
            }

            String newDirs  = Path.InternalCombine(FullPath, path);
            String fullPath = Path.GetFullPathInternal(newDirs);

            if (0 != String.Compare(FullPath, 0, fullPath, 0, FullPath.Length, true))
            {
                throw new ArgumentException(String.Format("Argument_InvalidSubPath", path, OriginalPath));
            }

            Directory.InternalCreateDirectory(fullPath, path);
            return(new DirectoryInfo(fullPath, false));
        }
示例#7
0
 public void Create()
 {
     Directory.InternalCreateDirectory(FullPath, OriginalPath, null);
 }
示例#8
0
 public void Create(DirectorySecurity directorySecurity)
 {
     Directory.InternalCreateDirectory(FullPath, OriginalPath, directorySecurity, true);
 }
 public void Create(DirectorySecurity directorySecurity)
 {
     Directory.InternalCreateDirectory(base.FullPath, base.OriginalPath, directorySecurity);
 }
 public void Create()
 {
     Directory.InternalCreateDirectory(base.FullPath, base.OriginalPath, null);
 }