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


C# FileSystem类代码示例

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


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


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