当前位置: 首页>>代码示例>>C#>>正文


C# IFileSystem.CreateDirectory方法代码示例

本文整理汇总了C#中IFileSystem.CreateDirectory方法的典型用法代码示例。如果您正苦于以下问题:C# IFileSystem.CreateDirectory方法的具体用法?C# IFileSystem.CreateDirectory怎么用?C# IFileSystem.CreateDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IFileSystem的用法示例。


在下文中一共展示了IFileSystem.CreateDirectory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ExtractFont

		internal static string ExtractFont(string name, IApplicationPaths paths, IFileSystem fileSystem)
        {
            var filePath = Path.Combine(paths.ProgramDataPath, "fonts", name);

			if (fileSystem.FileExists(filePath))
            {
                return filePath;
            }

            var namespacePath = typeof(PlayedIndicatorDrawer).Namespace + ".fonts." + name;
            var tempPath = Path.Combine(paths.TempDirectory, Guid.NewGuid().ToString("N") + ".ttf");
			fileSystem.CreateDirectory(Path.GetDirectoryName(tempPath));

            using (var stream = typeof(PlayedIndicatorDrawer).Assembly.GetManifestResourceStream(namespacePath))
            {
                using (var fileStream = new FileStream(tempPath, FileMode.Create, FileAccess.Write, FileShare.Read))
                {
                    stream.CopyTo(fileStream);
                }
            }

			fileSystem.CreateDirectory(Path.GetDirectoryName(filePath));

            try
            {
				fileSystem.CopyFile(tempPath, filePath, false);
            }
            catch (IOException)
            {

            }

            return tempPath;
        }
开发者ID:rezafouladian,项目名称:Emby,代码行数:34,代码来源:PlayedIndicatorDrawer.cs

示例2: Setup

        public void Setup()
        {
            theFileSystem = new FileSystem();

			theDirectory = Path.GetTempPath().AppendRandomPath();
            theFileSystem.CreateDirectory(theDirectory);

            createFile("1.txt");
            createFile("2.txt");
            createFile("3.txt");

            createDirectory("A");
            createFile("A", "A1.txt");
            createFile("A", "A2.txt");
            createFile("A", "A3.txt");

            createDirectory("B");
            createFile("B", "B1.txt");

            createDirectory("C");
            createFile("C", "C1.txt");
            createFile("C", "C2.txt");

            theFileSystem.ForceClean(theDirectory);
        }
开发者ID:modulexcite,项目名称:ripple,代码行数:25,代码来源:ForceDeleteTester.cs

示例3: EnsureList

        /// <summary>
        /// Ensures the list.
        /// </summary>
        /// <param name="url">The URL.</param>
        /// <param name="file">The file.</param>
        /// <param name="httpClient">The HTTP client.</param>
        /// <param name="fileSystem">The file system.</param>
        /// <param name="semaphore">The semaphore.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>Task.</returns>
        public static async Task EnsureList(string url, string file, IHttpClient httpClient, IFileSystem fileSystem, SemaphoreSlim semaphore, CancellationToken cancellationToken)
        {
            var fileInfo = fileSystem.GetFileInfo(file);

            if (!fileInfo.Exists || (DateTime.UtcNow - fileSystem.GetLastWriteTimeUtc(fileInfo)).TotalDays > 1)
            {
                await semaphore.WaitAsync(cancellationToken).ConfigureAwait(false);

                try
                {
                    var temp = await httpClient.GetTempFile(new HttpRequestOptions
                    {
                        CancellationToken = cancellationToken,
                        Progress = new Progress<double>(),
                        Url = url

                    }).ConfigureAwait(false);

					fileSystem.CreateDirectory(Path.GetDirectoryName(file));

					fileSystem.CopyFile(temp, file, true);
                }
                finally
                {
                    semaphore.Release();
                }
            }
        }
开发者ID:paul-777,项目名称:Emby,代码行数:38,代码来源:ImageUtils.cs

示例4: CreateNewDirectoryWithRenameAttempts

        public static string CreateNewDirectoryWithRenameAttempts(string directoryName, IFileSystem fileSystem, int maxRenameAttempts)
        {
            for (int directoryCreationAttempt = 1; directoryCreationAttempt < maxRenameAttempts; directoryCreationAttempt++)
            {
                string numberedDirectoryName;
                if (directoryCreationAttempt == 1)
                {
                    numberedDirectoryName = directoryName;
                }
                else
                {
                    string fullPath = Path.GetFullPath(directoryName);
                    string noTrailingSlash;
                    if (fullPath.EndsWith("\\"))
                    {
                        noTrailingSlash = fullPath.Substring(0, fullPath.Length - 1);
                    }
                    else
                    {
                        noTrailingSlash = fullPath;
                    }
                    numberedDirectoryName = string.Format("{0} ({1})", noTrailingSlash, directoryCreationAttempt.ToString());
                }

                if (fileSystem.DirectoryExists(numberedDirectoryName))
                {
                    continue;
                }

                fileSystem.CreateDirectory(numberedDirectoryName);
                return numberedDirectoryName;
            }

            throw new Exception(string.Format("Could not create directory: {0}. Exceeded {1} attempts.", directoryName, maxRenameAttempts));
        }
开发者ID:jzajac2,项目名称:AllYourTexts,代码行数:35,代码来源:FileCreator.cs

示例5: Setup

        public void Setup()
        {
            theFileSystem = new FileSystem();

            theDirectory = Guid.NewGuid().ToString();
            theFileSystem.CreateDirectory(theDirectory);

            createFile("1.txt");
            createFile("2.txt");
            createFile("3.txt");

            createDirectory("A");
            createFile("A", "A1.txt");
            createFile("A", "A2.txt");
            createFile("A", "A3.txt");

            createDirectory("B");
            createFile("B", "B1.txt");

            createDirectory("C");
            createFile("C", "C1.txt");
            createFile("C", "C2.txt");

            theFileSystem.ForceClean(theDirectory);
        }
开发者ID:ventaur,项目名称:ripple,代码行数:25,代码来源:ForceDeleteTester.cs

示例6: Move

        public void Move(IFileSystem source, FileSystemPath sourcePath, IFileSystem destination, FileSystemPath destinationPath)
        {
            bool isFile;
            if ((isFile = sourcePath.IsFile) != destinationPath.IsFile)
                throw new ArgumentException("The specified destination-path is of a different type than the source-path.");

            if (isFile)
            {
                using (var sourceStream = source.OpenFile(sourcePath, FileAccess.Read))
                {
                    using (var destinationStream = destination.CreateFile(destinationPath))
                    {
                        byte[] buffer = new byte[BufferSize];
                        int readBytes;
                        while ((readBytes = sourceStream.Read(buffer, 0, buffer.Length)) > 0)
                            destinationStream.Write(buffer, 0, readBytes);
                    }
                }
                source.Delete(sourcePath);
            }
            else
            {
                destination.CreateDirectory(destinationPath);
                foreach (var ep in source.GetEntities(sourcePath).ToArray())
                {
                    var destinationEntityPath = ep.IsFile
                                                    ? destinationPath.AppendFile(ep.EntityName)
                                                    : destinationPath.AppendDirectory(ep.EntityName);
                    Move(source, ep, destination, destinationEntityPath);
                }
                if (!sourcePath.IsRoot)
                    source.Delete(sourcePath);
            }
        }
开发者ID:readelivery,项目名称:sharpfilesystem,代码行数:34,代码来源:StandardEntityMover.cs

示例7: JsonLocalizationCache

 public JsonLocalizationCache(IHostingEnvironment hostingEnvironment, IFileSystem fileSystem, ILoggerFactory loggerFactory)
 {
     _path = hostingEnvironment.MapPath(@"json");
     _fileSystem = fileSystem;
     _logger = loggerFactory.CreateLogger<JsonLocalizationCache>();
     _fileSystem.CreateDirectory(_path);
     _fileSystem.Watch(_path, "*.json", OnChanged);
 }
开发者ID:jakvike,项目名称:Localization,代码行数:8,代码来源:JsonLocalizationCache.cs

示例8: Execute

        public void Execute(IFileSystem fileSystem)
        {
            fileSystem.CreateDirectory(this.fullDirectoryPath);

            foreach (var fileHierarchyNode in this.children)
            {
                fileHierarchyNode.Execute(fileSystem);
            }
        }
开发者ID:tygerbytes,项目名称:ResourceFitness,代码行数:9,代码来源:FileHierarchyDirectoryNode.cs

示例9: UacCompliantPaths

        public UacCompliantPaths(IFileSystem fileSystem)
        {
            var absoluteDataPath = Environment.ExpandEnvironmentVariables(appFolder);

            fileSystem.CreateDirectory(absoluteDataPath);

            Data = absoluteDataPath;
            Application = AppDomain.CurrentDomain.BaseDirectory;
            EnureWorkingDirectory();
        }
开发者ID:NoxWings,项目名称:FreePIE,代码行数:10,代码来源:UacCompliantPaths.cs

示例10: ExecuteCreation

 /// <summary>
 /// Executes the creation of the folder.
 /// </summary>
 public void ExecuteCreation(IFileSystem fileSystem)
 {
     try
     {
         fileSystem.CreateDirectory(_associatedPath);
     }
     catch //(DuplicateDirectoryException)
     {
         // ADD SOMETHING TO LOG?
     }
 }
开发者ID:Yndal,项目名称:BDSA-Project-2012,代码行数:14,代码来源:FolderCreation.cs

示例11: SetUp

        public void SetUp()
        {
            theSolution = new Solution
            {
                Directory = "SolutionFiles"
            };

            theFileSystem = new FileSystem();
            theFileSystem.CreateDirectory("SolutionFiles");

            theSolutionFiles = new SolutionFiles(theFileSystem, new SolutionLoader());
            theSolutionFiles.RootDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SolutionFiles");

            theFileSystem.CreateDirectory("SolutionFiles", "src");

            theFileSystem.CreateDirectory("SolutionFiles", "src", "Project1");
            theFileSystem.CreateDirectory("SolutionFiles", "src", "Project2");

            theFileSystem.WriteStringToFile(Path.Combine("SolutionFiles", "src", "Project1", "Project1.csproj"), "test");
            theFileSystem.WriteStringToFile(Path.Combine("SolutionFiles", "src", "Project2", "Project2.csproj"), "test");
        }
开发者ID:ventaur,项目名称:ripple,代码行数:21,代码来源:SolutionFilesTester.cs

示例12: SetUp

        public void SetUp()
        {
            theSolution = new Solution
            {
                Directory = "SolutionFiles"
            };

            theFileSystem = new FileSystem();
            theFileSystem.CreateDirectory("SolutionFiles");

            theSolutionFiles = new SolutionFiles(theFileSystem, new SolutionLoader());
            theSolutionFiles.RootDir = Path.GetTempPath().AppendRandomPath();

            theFileSystem.CreateDirectory("SolutionFiles", "src");

            theFileSystem.CreateDirectory("SolutionFiles", "src", "Project1");
            theFileSystem.CreateDirectory("SolutionFiles", "src", "Project2");

            theFileSystem.WriteStringToFile(Path.Combine("SolutionFiles", "src", "Project1", "Project1.csproj"), "test");
            theFileSystem.WriteStringToFile(Path.Combine("SolutionFiles", "src", "Project2", "Project2.csproj"), "test");
        }
开发者ID:4lexm,项目名称:ripple,代码行数:21,代码来源:SolutionFilesTester.cs

示例13: CopyFilesRecursively

 public static void CopyFilesRecursively(DirectoryInfo source, string targetVirtualPath, IFileSystem fs)
 {
     foreach (DirectoryInfo dir in source.GetDirectories())
     {
         string newDirVirtualPath = Path.Combine(targetVirtualPath, dir.Name);
         fs.CreateDirectory(newDirVirtualPath);
         CopyFilesRecursively(dir, newDirVirtualPath, fs);
     }
     foreach (FileInfo file in source.GetFiles())
     {
         fs.WriteFile(Path.Combine(targetVirtualPath, file.Name), file.OpenRead());
     }
 }
开发者ID:GrimaceOfDespair,项目名称:n2cms,代码行数:13,代码来源:FileSystemTests.cs

示例14: Copy

 public void Copy(IFileSystem source, FileSystemPath sourcePath, IFileSystem destination, FileSystemPath destinationPath)
 {
     var pSource = (PhysicalFileSystem)source;
     var pDestination = (PhysicalFileSystem)destination;
     var pSourcePath = pSource.GetPhysicalPath(sourcePath);
     var pDestinationPath = pDestination.GetPhysicalPath(destinationPath);
     if (sourcePath.IsFile)
         System.IO.File.Copy(pSourcePath, pDestinationPath);
     else
     {
         destination.CreateDirectory(destinationPath);
         foreach(var e in source.GetEntities(sourcePath))
             source.Copy(e, destination, e.IsFile ? destinationPath.AppendFile(e.EntityName) : destinationPath.AppendDirectory(e.EntityName));
     }
 }
开发者ID:HaKDMoDz,项目名称:eStd,代码行数:15,代码来源:PhysicalEntityMover.cs

示例15: Import

        public void Import(IFileSystem fs, Attachment a)
        {
            if (a.HasContents)
            {
                string path = a.Url;

                if(!fs.DirectoryExists(Path.GetDirectoryName(path)))
                {
                    fs.CreateDirectory(Path.GetDirectoryName(path));
                }

                var memoryStream = new MemoryStream(a.FileContents);
                fs.WriteFile(path, memoryStream);
            }
        }
开发者ID:GrimaceOfDespair,项目名称:n2cms,代码行数:15,代码来源:FileAttachmentAttribute.cs


注:本文中的IFileSystem.CreateDirectory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。