• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# FileSystem类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中FileSystem的典型用法代码示例。如果您正苦于以下问题:C# FileSystem类的具体用法?C# FileSystem怎么用?C# FileSystem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



FileSystem类属于命名空间,在下文中一共展示了FileSystem类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: SetUp

 public void SetUp()
 {
     fileSystem = Substitute.For<FileSystem>((Config)null);
     fileSystem.ReadXmlFile().Returns(Resource.SimpleSource);
     timeContext = Substitute.For<TimeContext>();
     sut = new XmlDataModificator(timeContext, fileSystem);
 }
开发者ID:ragnarekmix,项目名称:Global.License,代码行数:7,代码来源:XmlDataModificatorTests.cs


示例2: RenameClasses

        public void RenameClasses()
        {
            var folder = ".".ToFullPath().ParentDirectory().ParentDirectory()
                .AppendPath("CodeTracker");

            var fileSystem = new FileSystem();
            var files = fileSystem.FindFiles(folder, FileSet.Shallow("*.json"));

            

            foreach (var file in files)
            {
                var json = fileSystem.ReadStringFromFile(file);

                json = replace(json, "GithubProject");
                json = replace(json, "Timestamped[]");
                json = replace(json, "ProjectStarted");
                json = replace(json, "IssueCreated");
                json = replace(json, "IssueClosed");
                json = replace(json, "IssueReopened");
                json = replace(json, "Commit");


                fileSystem.WriteStringToFile(file, json);
            }

        }
开发者ID:phillip-haydon,项目名称:marten,代码行数:27,代码来源:AsyncDaemonFixture.cs


示例3: Extract

        public static void Extract(this ZipArchive archive, FileSystem fileSystem, string directoryName)
        {
            foreach (ZipArchiveEntry entry in archive.Entries)
            {
                string path = Path.Combine(directoryName, entry.FullName);
                if (entry.Length == 0 && (path.EndsWith("/", StringComparison.Ordinal) || path.EndsWith("\\", StringComparison.Ordinal)))
                {
                    // Extract directory
                    fileSystem.Directory.CreateDirectory(path);
                }
                else
                {
                    FileInfoBase fileInfo = fileSystem.FileInfo.FromFileName(path);

                    if (!fileInfo.Directory.Exists)
                    {
                        fileInfo.Directory.Create();
                    }

                    using (Stream zipStream = entry.Open(),
                                  fileStream = fileInfo.OpenWrite())
                    {
                        zipStream.CopyTo(fileStream);
                    }
                }
            }
        }
开发者ID:GregPerez83,项目名称:kudu,代码行数:27,代码来源:ZipArchiveExtensions.cs


示例4: can_read_and_write_the_packages_config

		public void can_read_and_write_the_packages_config()
		{
			var theFileSystem = new FileSystem();

			theFileSystem.WriteStringToFile(NuGetDependencyStrategy.PackagesConfig, "<?xml version=\"1.0\" encoding=\"utf-8\"?><packages></packages>");
			
			var theSolution = new Solution();
			theSolution.AddDependency(new Dependency("Bottles", "1.0.1.1"));
			theSolution.AddDependency(new Dependency("FubuCore", "1.2.0.1"));

			var theProject = new Project("Test.csproj");
			theProject.AddDependency("Bottles");
			theProject.AddDependency("FubuCore");

			theSolution.AddProject(theProject);

			var theStrategy = new NuGetDependencyStrategy();
			theStrategy.Write(theProject);

			theStrategy
				.Read(theProject)
				.ShouldHaveTheSameElementsAs(
					new Dependency("Bottles", "1.0.1.1"),
					new Dependency("FubuCore", "1.2.0.1")
				);

			theFileSystem.DeleteFile(NuGetDependencyStrategy.PackagesConfig);
		}
开发者ID:modulexcite,项目名称:ripple,代码行数:28,代码来源:NugetDependencyStrategyTester.cs


示例5: DoNotCompressAlreadyCompressedFiles

        public void DoNotCompressAlreadyCompressedFiles()
        {
            // Arrange
            //FileHandler fileHandler = new JpgFileHandler();

            var fileSystem = new FileSystem();
            fileSystem.DeleteDirectoryAndAllFiles(TestConstants.NewDirectory);
            fileSystem.DeleteDirectoryAndAllFiles(TestConstants.TempDirectory);
            IFileHandler fileHandler = _fileHandlerFactory.GetFileHandler(TestConstants.ExistingJpgFullFileName, fileSystem);
            IPictureDirectory tempDir = _directoryFactory.GetOrCreateDirectory(TestConstants.TempDirectory);
            IPictureDirectory newDir = _directoryFactory.GetOrCreateDirectory(TestConstants.NewDirectory);
            string originalFileName = fileHandler.FileName;
            string tempFileName = fileHandler.PerformRenameAndMove(tempDir);
            string compressedFileName = fileHandler.PerformCompressAndMove(newDir);
            bool caughtExpectedException = false;

            // Act
            try {
                string compressedFileName2 = fileHandler.PerformCompressAndMove(tempDir);
            } catch (IOException) {
                caughtExpectedException = true;
            }

            // Assert
            Assert.IsTrue(caughtExpectedException);
        }
开发者ID:JMnITup,项目名称:PictureHandler,代码行数:26,代码来源:CompressionTests.cs


示例6: LoadAllProjects

        public void LoadAllProjects()
        {
            var fileSystem = new FileSystem();

            var folder = AppContext.BaseDirectory;
            while (!folder.EndsWith("Marten.Testing"))
            {
                folder = folder.ParentDirectory();
            }

            folder = folder.AppendPath("CodeTracker");

            var files = fileSystem.FindFiles(folder, FileSet.Shallow("*.json"));

            AllProjects = new Dictionary<Guid, GithubProject>();
            foreach (var file in files)
            {
                var project = GithubProject.LoadFrom(file);
                AllProjects.Add(project.Id, project);

                Console.WriteLine($"Loaded {project.OrganizationName}{project.ProjectName} from JSON");
            }

            _store.Advanced.Clean.DeleteAllDocuments();
            PublishAllProjectEvents(_store);
        }
开发者ID:tim-cools,项目名称:Marten,代码行数:26,代码来源:AsyncDaemonFixture.cs


示例7: LuxConfigHost

 public LuxConfigHost(IInternalConfigHost internalConfigHost)
 {
     FileSystem = new FileSystem();
     if (ConfigSystemProxy.FileSystem != null)
         FileSystem = ConfigSystemProxy.FileSystem;
     Host = internalConfigHost;
 }
开发者ID:LazyTarget,项目名称:Lux,代码行数:7,代码来源:LuxConfigHost.cs


示例8: CreateChildDirectory

 public IDirectory CreateChildDirectory(string name)
 {
     var newPath = System.IO.Path.Combine(Path, name);
     var fileSystem = new FileSystem();
     fileSystem.CreateDirectory(newPath);
     return fileSystem.GetDirectory(newPath);
 }
开发者ID:tpeplow,项目名称:Projector,代码行数:7,代码来源:FileSystem.cs


示例9: Execute

        public void Execute(string[] arguments)
        {
            Settings.Parse(arguments);

            var fileSystem = new FileSystem();

            if (string.IsNullOrWhiteSpace(Path))
            {
                Path = Directory.GetCurrentDirectory();
            }

            if (string.IsNullOrWhiteSpace(Engine))
            {
                Engine = InferEngineFromDirectory(Path, fileSystem);
            }

            ISiteEngine engine;

            if (engineMap.TryGetValue(Engine, out engine))
            {
                var context = new SiteContext { Folder = Path };
                engine.Initialize(fileSystem, context);
                engine.Process();
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("Cannot find engine for input: '{0}'", Engine);
            }
        }
开发者ID:bdukes,项目名称:pretzel,代码行数:29,代码来源:BakeCommand.cs


示例10: AsyncDaemonFixture

        public AsyncDaemonFixture()
        {
            _store = TestingDocumentStore.For(_ =>
            {
                _.DatabaseSchemaName = "expected";
                _.Events.DatabaseSchemaName = "expected";

                _.Events.InlineProjections.AggregateStreamsWith<ActiveProject>();
                _.Events.InlineProjections.TransformEvents(new CommitViewTransform());
            });

            var folder = ".".ToFullPath().ParentDirectory().ParentDirectory()
                .AppendPath("CodeTracker");

            var files = new FileSystem().FindFiles(folder, FileSet.Shallow("*.json"));

            AllProjects = new Dictionary<Guid, GithubProject>();
            foreach (var file in files)
            {
                var project = GithubProject.LoadFrom(file);
                AllProjects.Add(project.Id, project);

                Console.WriteLine($"Loaded {project.OrganizationName}{project.ProjectName} from JSON");
            }

            PublishAllProjectEvents(_store);
        }
开发者ID:danielmarbach,项目名称:marten,代码行数:27,代码来源:AsyncDaemonFixture.cs


示例11: serviceConfiguration

		private static BottleServiceConfiguration serviceConfiguration()
		{
			var directory = BottlesServicePackageFacility.GetApplicationDirectory();
			var fileSystem = new FileSystem();

			return fileSystem.LoadFromFile<BottleServiceConfiguration>(directory, BottleServiceConfiguration.FILE);
		}
开发者ID:DarthFubuMVC,项目名称:Bottles.Services,代码行数:7,代码来源:Program.cs


示例12: RefreshAssemblies

        private static void RefreshAssemblies(ILog log)
        {
            var fileSystem = new FileSystem();

            var packagesFolder = Path.Combine(fileSystem.CurrentDirectory, "packages");

            if(fileSystem.DirectoryExists(packagesFolder))
            {
                // Delete any blacklisted packages to avoid various issues with PackageAssemblyResolver
                // https://github.com/scriptcs/scriptcs/issues/511
                foreach (var packagePath in
                    _blacklistedPackages.SelectMany(packageName => Directory.GetDirectories(packagesFolder)
                                .Where(d => new DirectoryInfo(d).Name.StartsWith(packageName, StringComparison.InvariantCultureIgnoreCase)),
                                (packageName, packagePath) => new {packageName, packagePath})
                        .Where(t => fileSystem.DirectoryExists(t.packagePath))
                        .Select(t => @t.packagePath))
                {
                    fileSystem.DeleteDirectory(packagePath);
                }
            }

            var par = new PackageAssemblyResolver(fileSystem, new PackageContainer(fileSystem, log), log);

            _assemblies = par.GetAssemblyNames(fileSystem.CurrentDirectory).ToList();

            // Add the assemblies in the current directory
            _assemblies.AddRange(Directory.GetFiles(fileSystem.CurrentDirectory, "*.dll")
                .Where(a => new AssemblyUtility().IsManagedAssembly(a)));
        }
开发者ID:kiwidev,项目名称:mmbot,代码行数:29,代码来源:NuGetPackageAssemblyResolver.cs


示例13: ForSolution

        public static PersistenceExpression<Solution> ForSolution(Solution target)
        {
            var file = "{0}-{1}.config".ToFormat(typeof(Solution).Name, Guid.NewGuid());
            var fileSystem = new FileSystem();

            if (fileSystem.FileExists(file))
            {
                fileSystem.DeleteFile(file);
            }

            var writer = ObjectBlockWriter.Basic(new RippleBlockRegistry());
            var contents = writer.Write(target);
            Debug.WriteLine(contents);
            fileSystem.WriteStringToFile(file, contents);

            var reader = SolutionLoader.Reader();

            var specification = new PersistenceSpecification<Solution>(x =>
            {
                var fileContents = fileSystem.ReadStringFromFile(file);
                var readValue = Solution.Empty(); 
                reader.Read(readValue, fileContents);

                fileSystem.DeleteFile(file);

                return readValue;
            });

            specification.Original = target;

            return new PersistenceExpression<Solution>(specification);
        }
开发者ID:modulexcite,项目名称:ripple,代码行数:32,代码来源:CheckObjectBlockPersistence.cs


示例14: Main

        public static int Main(string[] args)
        {
            var fileSystem = new FileSystem();

            string srcDirectory = AppDomain.CurrentDomain.BaseDirectory.ParentDirectory().ParentDirectory().ParentDirectory().ParentDirectory();
            string buildDirectory = args.Any()
                                        ? args.Single()
                                        : srcDirectory.ParentDirectory().ParentDirectory().AppendPath("buildsupport");

            Console.WriteLine("Trying to copy to " + buildDirectory);
            if (!fileSystem.DirectoryExists(buildDirectory))
            {
                throw new ApplicationException("Could not find the buildsupport directory");
            }

            var targetDirectory = buildDirectory.AppendPath("FubuDocs");

            fileSystem.CreateDirectory(targetDirectory);
            fileSystem.CleanDirectory(targetDirectory);

            var fromDirectory = srcDirectory.AppendPath("FubuDocsRunner").AppendPath("bin").AppendPath("debug");
            var files = FileSet.Deep("*.dll;*.pdb;*.exe");
            fileSystem.FindFiles(fromDirectory, files).Each(file => {
                Console.WriteLine("Copying {0} to {1}", file, targetDirectory);
                fileSystem.Copy(file, targetDirectory, CopyBehavior.overwrite);
            });

            return 0;
        }
开发者ID:mtscout6,项目名称:FubuWorld,代码行数:29,代码来源:Program.cs


示例15: generate_visualizers

        public void generate_visualizers()
        {
            var path = @"C:\code\diagnostics\src\FubuMVC.Diagnostics\Visualization\Visualizers\ConfigurationActions";

            var types = typeof (FubuRequest).Assembly.GetExportedTypes()
                .Where(x => x.IsConcreteTypeOf<IConfigurationAction>());

            var fileSystem = new FileSystem();

            types.Each(x =>
            {
                var writer = new StringWriter();
                /*
            <use master="" />
            <viewdata model="FubuMVC.Diagnostics.Visualization.BehaviorNodeViewModel" />
                 */
                writer.WriteLine("<use master=\"\" />");
                writer.WriteLine("<viewdata model=\"{0}\" />", x.FullName);

                var file = path.AppendPath(x.Name + ".spark");

                fileSystem.WriteStringToFile(file, writer.ToString());

            });
        }
开发者ID:jbogard,项目名称:fubumvc,代码行数:25,代码来源:debugging.cs


示例16: Access

		virtual protected void Access(String Path, out FileSystem NewFileSystem, out String NewPath)
		{
			// Normalize Components
			Path = AbsoluteNormalizePath(Path, CurrentWorkingPath);
			var ComparePath = ComparablePath(Path);

			// Check MountedFileSystems.
			foreach (var Item in MountedFileSystems)
			{
				var CheckMountedPath = ComparablePath(Item.Key);
				var MountInfo = Item.Value;

				if (
					ComparePath.StartsWith(CheckMountedPath) &&
					(
						(CheckMountedPath.Length == ComparePath.Length) ||
						(ComparePath.Substring(CheckMountedPath.Length, 1) == "/")
					)
				) {
					var NewAccessPath = ComparePath.Substring(CheckMountedPath.Length);
					if (MountInfo.Path != "/")
					{
						NewAccessPath = MountInfo.Path + "/" + NewAccessPath;
					}
					// Use Mounted File System.
					MountInfo.FileSystem.Access(NewAccessPath, out NewFileSystem, out NewPath);
					return;
				}
			}
			NewFileSystem = this;
			NewPath = Path;
		}
开发者ID:soywiz,项目名称:csharputils,代码行数:32,代码来源:BaseFileSystem.cs


示例17: CreateFileFromResourceName

		public static void CreateFileFromResourceName(string resourceName, string path)
		{
			var fileSystem = new FileSystem();
			using (var resourceStream = GetResourceStreamFromResourceName(resourceName)) {
				fileSystem.WriteStreamToFile(path, resourceStream);
			}
		}
开发者ID:wilsonmar,项目名称:mulder,代码行数:7,代码来源:TestFileCreation.cs


示例18: SetUp

        public void SetUp()
        {
            var fileSystem = new FileSystem();

            fileSystem.Copy("FubuMVC.SlickGrid.Docs.csproj.fake", "FubuMVC.SlickGrid.Docs.csproj");
            fileSystem.Copy("SlickGridHarness.csproj.fake", "SlickGridHarness.csproj");
        }
开发者ID:awelburn,项目名称:FubuCsProjFile,代码行数:7,代码来源:AssemblyReferenceTester.cs


示例19: GenerateDeployScript_should_generate_correct_script_on_disk

        public void GenerateDeployScript_should_generate_correct_script_on_disk()
        {
            var generator = new SqlScriptGenerator();
            SqlScriptingInput input = generator.GetSqlScriptingInput(@"dsql02.ada-dev.nl\v2012", @"SMS");
            input.RootFolder = @"C:\Temp\Generated";

            SqlDeployScriptResult result = generator.GenerateDeployScript(input);
            string template = Assembly.GetExecutingAssembly().GetFileAsString("Research.EndToEndTests.CodeGeneration.SqlScriptGeneratorTester_GenerateDatabaseDeployScript_result.cmd");  

            string content = string.Format(template, result.Schemas, result.Tables, result.Functions, result.StoredProcedures);

            var file = new FileInfoDto
            {
                Path = Path.Combine(input.RootFolder, "Deploy.cmd")
            };
            file.Content = content;

            var fs = new FileSystem();
            Task deleteDirectoryTask = fs.DeleteDirectoryAsync(input.RootFolder);
            deleteDirectoryTask.Wait();

            Task generateFilesTask = fs.GenerateFileAsync(file);
            generateFilesTask.Wait();

            Assert.AreEqual(true, true);
        }
开发者ID:husni1992,项目名称:Research,代码行数:26,代码来源:SqlScriptGeneratorTester.cs


示例20: LoadSampleCommands

        private void LoadSampleCommands()
        {
            var fileSystem = new FileSystem();
            var commandSymbols = new List<string> { ":", "#" };
            var fileContents = new StringBuilder();
            var path = fileSystem.GetWorkingDirectory(fileSystem.CurrentDirectory);
            var files = fileSystem.EnumerateFiles(path, "*.scriptcommands", SearchOption.TopDirectoryOnly);

            foreach (var fileName in files.Select(file => Path.Combine(fileSystem.CurrentDirectory, file)))
            {
                using (TextReader textReader = new StreamReader(fileName))
                {
                    fileContents.AppendFormat("{0}", textReader.ReadToEnd());
                }
            }

            var commandstoParse = fileContents.ToString();
            if (string.IsNullOrWhiteSpace(commandstoParse)) return;

            var commandScripts = SplitLines(commandstoParse);

            foreach (var command in commandScripts.Where(command => !string.IsNullOrWhiteSpace(command)))
            {
                var commandNameLength = command.IndexOf("]", StringComparison.Ordinal);
                var commandName = command.Substring(0, commandNameLength);
                var commandScript = command.Substring(commandNameLength + 1);
                ReplCommandPackUtils.MapCommand(SampleCommands, commandName, commandScript, commandSymbols);
            }
        }
开发者ID:ktroach,项目名称:scriptcs-replcommand-sample-pack,代码行数:29,代码来源:ReplCommandScriptSamples.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# FileSystemEventHandler类代码示例发布时间:2022-05-24
下一篇:
C# FileStream类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap