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

C# IO.FileSystem类代码示例

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

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



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

示例1: VerifyCanOverride

        public void VerifyCanOverride()
        {
            IFileSystem fileSystem = new FileSystem();
            var root = Path.GetPathRoot(AppDomain.CurrentDomain.BaseDirectory);
            var settings = new DeploymentSettings(root.AppendPath("dev", "test-profile"));
            IBottleRepository bottles = new BottleRepository(fileSystem, new ZipFileService(fileSystem), settings);

            var initializer = new WebAppOfflineInitializer(fileSystem);

            var deployer = new IisWebsiteCreator();

            var directive = new Website();
            directive.WebsiteName = "fubu";
            directive.WebsitePhysicalPath = root.AppendPath("dev", "test-web");
            directive.VDir = "bob";
            directive.VDirPhysicalPath = root.AppendPath("dev", "test-app");
            directive.AppPool = "fubizzle";

            directive.DirectoryBrowsing = Activation.Enable;

            initializer.Execute(directive, new HostManifest("something"), new PackageLog());

            deployer.Create(directive);

            //override test
            directive.ForceWebsite = true;
            directive.VDirPhysicalPath = root.AppendPath("dev", "test-app2");
            deployer.Create(directive);
        }
开发者ID:rsanders1,项目名称:bottles,代码行数:29,代码来源:IntegrationIisFubuDeploymentTester.cs


示例2: before_all

        public void before_all()
        {
            // setup
            _command = new NewCommand();
            _fileSystem = new FileSystem();
            _zipService = new ZipFileService(_fileSystem);
            _commandInput = new NewCommandInput();

            tmpDir = FileSystem.Combine("Templating", Guid.NewGuid().ToString());
            repoZip = FileSystem.Combine("Templating", "repo.zip");
            _zipService.ExtractTo(repoZip, tmpDir, ExplodeOptions.DeleteDestination);

            solutionFile = FileSystem.Combine("Templating", "sample", "myproject.txt");
            oldContents = _fileSystem.ReadStringFromFile(solutionFile);
            solutionDir = _fileSystem.GetDirectory(solutionFile);

            _commandInput.GitFlag = "file:///{0}".ToFormat(_fileSystem.GetFullPath(tmpDir).Replace("\\", "/"));
            _commandInput.ProjectName = "MyProject";
            _commandInput.SolutionFlag = solutionFile;
            _commandInput.OutputFlag = solutionDir;
            _commandInput.RakeFlag = "init.rb";

            _commandResult = _command.Execute(_commandInput);

            newSolutionContents = _fileSystem.ReadStringFromFile(solutionFile);
        }
开发者ID:wbinford,项目名称:fubu,代码行数:26,代码来源:NewCommandEndToEndTester.cs


示例3: Export

        /// <summary>
        /// Export data into CSV format
        /// </summary>
        public CFile Export(FileSystem fs, ExportRow.ExportRowList rows)
        {
            int i;
            MemoryStream csvstream = new MemoryStream();
            StreamWriter csvwriter = new StreamWriter(csvstream);

            //Write the data out in CSV style rows
            foreach (ExportRow row in rows) {
                for (i = 0; i < row.Fields.Count; i++) {
                    csvwriter.Write(row.Fields[i]);
                    if (i < row.Fields.Count-1)
                        csvwriter.Write(",");
                }
                csvwriter.WriteLine();
            }
            csvwriter.Flush();

            //Commit to a temp file within the FS
            //Create a temp file
            Guid guid = Guid.NewGuid();
            CFile expfile = fs.CreateFile(@"c:\system\export\" + guid.ToString(), false,
                new CFilePermission.FilePermissionList() );
            expfile.Name = expfile.ID + ".csv";
            fs.UpdateFileInfo(expfile, false);

            //Commit the data
            csvstream.Seek(0, SeekOrigin.Begin);
            expfile.RawData = Globals.ReadStream(csvstream, (int) csvstream.Length);
            fs.Edit(expfile);
            fs.Save(expfile);

            csvwriter.Close();

            return expfile;
        }
开发者ID:padilhalino,项目名称:FrontDesk,代码行数:38,代码来源:csvexporter.cs


示例4: should_throw_when_file_does_not_exist

        public void should_throw_when_file_does_not_exist()
        {
            var fileSystem = new FileSystem();
            const string fileName = "does not exist";

            typeof(ApplicationException).ShouldBeThrownBy(() => fileSystem.LoadFromFileOrThrow<SerializeMe>(fileName));
        }
开发者ID:bobpace,项目名称:fubucore,代码行数:7,代码来源:FilesSystem_load_from_file.cs


示例5: SetUp

        public void SetUp()
        {
            var system = new FileSystem();
            system.DeleteDirectory("geonosis");
            system.CreateDirectory("geonosis");

            var data1 = newData();
            var data2 = newData();
            var data3 = newData();
            var data4 = newData();
            var data5 = newData();
            var data6 = newData();
            var data7 = newData();

            saveData(data1, "a", "a1");
            saveData(data2, "a", "a2");
            saveData(data3, "b", "b3");
            saveData(data4, "b", "b4");
            saveData(data5, "c", "c5");
            saveData(data6, "c", "c6");
            saveData(data7, "c", "c7");

            theCache = new PackageFilesCache();
            theCache.AddDirectory(FileSystem.Combine("geonosis", "a"));
            theCache.AddDirectory(FileSystem.Combine("geonosis", "b"));
            theCache.AddDirectory(FileSystem.Combine("geonosis", "c"));
        }
开发者ID:jericsmith,项目名称:fubumvc,代码行数:27,代码来源:PackageFilesIntegrationTester.cs


示例6: Setup

        public virtual void Setup()
        {
            _latestRecentBackupQuery = A.Fake<LatestRecentBackupQuery>();
            _fileSystem = A.Fake<FileSystem>();

            _defaultSettings = new BackupSettings { BackupTargetDestination = "TargetDestination" };
        }
开发者ID:splant,项目名称:OvernightTeamCityBackup,代码行数:7,代码来源:CopyLatestBackupStorageTaskTests.cs


示例7: Main

        static void Main(string[] args)
        {
            File.WriteAllText("pwd.txt", System.Environment.CurrentDirectory);
            log4net.Config.XmlConfigurator.ConfigureAndWatch(new FileInfo("log4net.config"));

            HostFactory.Run(h =>
            {
                h.SetDescription("Bottle Host");
                h.SetServiceName("bottle-host");
                h.SetDisplayName("display");

                h.Service<BottleHost>(c =>
                {
                    c.ConstructUsing(n =>
                    {
                        var fileSystem = new FileSystem();
                        var packageExploder = new PackageExploder(new ZipFileService(fileSystem),
                                                                  new PackageExploderLogger(ConsoleWriter.Write),
                                                                  fileSystem);
                        return new BottleHost(packageExploder, fileSystem);
                    });
                    c.WhenStarted(s => s.Start());
                    c.WhenStopped(s => s.Stop());
                });
            });
        }
开发者ID:jrios,项目名称:bottles,代码行数:26,代码来源:Program.cs


示例8: Page_Load

        private void Page_Load(object sender, System.EventArgs e)
        {
            lblError.Visible = false;

            byte[] fileData;
            CFile file = new FileSystem(Globals.CurrentIdentity).GetFile(Convert.ToInt32(Request.Params["FileID"]));
            string filename= file.Name;

            if (file.IsDirectory()) {
                fileData = GetDirectoryData(file);
                filename += ".zip";
            }
            else {
                try {
                    new FileSystem(Globals.CurrentIdentity).LoadFileData(file);
                } catch (CustomException er) {
                    PageError(er.Message);
                    return;
                }
                fileData = file.RawData;
            }

            Response.Clear();
            Response.ContentType = "application/octet-stream; name=" + filename;
            Response.AddHeader("Content-Disposition","attachment; filename=" + filename);
            Response.AddHeader("Content-Length", fileData.Length.ToString());
            Response.Flush();

            Response.OutputStream.Write(fileData, 0, fileData.Length);
            Response.Flush();
        }
开发者ID:padilhalino,项目名称:FrontDesk,代码行数:31,代码来源:dlfile.aspx.cs


示例9: FileSystemIntegrationTester

 public FileSystemIntegrationTester()
 {
     _testDirectory = new TestDirectory();
     _testDirectory.ChangeDirectory();
     _fileSystem = new FileSystem();
     _basePath = Path.GetTempPath();
 }
开发者ID:JasperFx,项目名称:baseline,代码行数:7,代码来源:FileSystemTester.cs


示例10: LoadFileBrowser

        public void LoadFileBrowser()
        {
            int i=0;
            tvFiles.Nodes.Clear();
            FileSystem fs = new FileSystem(Globals.CurrentIdentity);
            foreach(string droot in m_roots) {
                CFile dirroot = fs.GetFile(droot);

                TreeNode root = new TreeNode();
                root.Text = dirroot.Alias;
                root.ImageUrl = GetFolderIcon(dirroot);
                root.NodeData = dirroot.FullPath;
                root.Expandable = ExpandableValue.Always;
                tvFiles.Nodes.Add(root);

                if (i == 0 && ViewState["gridpath"] == null) {
                    ViewState["gridpath"] = dirroot.FullPath;
                    ExpandTreeNode(root);
                }
                ++i;
            }

            BindFileGrid();
            BindClipBoard();
        }
开发者ID:padilhalino,项目名称:FrontDesk,代码行数:25,代码来源:filebrowser.ascx.cs


示例11: before_each

 public void before_each()
 {
     _command = new NewCommand();
     _fileSystem = new FileSystem();
     _zipService = new ZipFileService(_fileSystem);
     _commandInput = new NewCommandInput();
 }
开发者ID:mmoore99,项目名称:fubumvc,代码行数:7,代码来源:NewCommandEndToEndTester.cs


示例12: FindSolutions

        public static IEnumerable<string> FindSolutions()
        {
            var currentDirectory = Environment.CurrentDirectory.ToFullPath();
            var files = new FileSystem().FindFiles(currentDirectory, FileSet.Deep("*.sln"));

            return files.Select(x => x.ToFullPath().PathRelativeTo(currentDirectory));
        }
开发者ID:jbogard,项目名称:fubumvc,代码行数:7,代码来源:SolutionFinder.cs


示例13: Load

		public Slide Load(FileInfo file, string unitName, int slideIndex, CourseSettings settings)
		{
			var sourceCode = file.ContentAsUtf8();
			var prelude = GetPrelude(file.Directory);
			var fs = new FileSystem(file.Directory);
			return SlideParser.ParseCode(sourceCode, new SlideInfo(unitName, file, slideIndex), prelude, fs);
		}
开发者ID:andgein,项目名称:uLearn,代码行数:7,代码来源:CSharpSlideLoader.cs


示例14: Main

        static void Main(string[] args)
        {
            setupLog4Net();

            HostFactory.Run(h =>
            {
                h.SetDescription("Bottle Host");
                h.SetServiceName("bottle-host");
                h.SetDisplayName("display");

                h.Service<BottleHost>(c =>
                {
                    c.ConstructUsing(n =>
                    {
                        var fileSystem = new FileSystem();
                        var packageExploder = new PackageExploder(new ZipFileService(fileSystem),
                                                                  new PackageExploderLogger(ConsoleWriter.Write),
                                                                  fileSystem);
                        return new BottleHost(packageExploder, fileSystem);
                    });
                    c.WhenStarted(s => s.Start());
                    c.WhenStopped(s => s.Stop());
                });
            });
        }
开发者ID:emiaj,项目名称:bottles,代码行数:25,代码来源:Program.cs


示例15: ExportTo

        public void ExportTo(string directory, Topic root, Func<Topic, string> pathing)
        {
            var fileSystem = new FileSystem();

            string sourceContent = _settings.Root.AppendPath("content");
            if (fileSystem.DirectoryExists(sourceContent))
            {
                fileSystem.CopyToDirectory(sourceContent, directory.AppendPath("content"));
            }

            root.AllTopicsInOrder().Each(topic =>
            {
                var path = pathing(topic);
                var parentDirectory = path.ParentUrl();

                if (parentDirectory.IsNotEmpty())
                {
                    fileSystem.CreateDirectory(directory.AppendPath(parentDirectory));
                }
                

                var text = _generator.Generate(topic);

                // Hoakum
                topic.Substitutions.Each((key, value) =>
                {
                    text = text.Replace(key, value);
                });

                fileSystem.WriteStringToFile(directory.AppendPath(path), text);
            });
        }
开发者ID:storyteller,项目名称:Storyteller,代码行数:32,代码来源:Exporter.cs


示例16: FindAssemblies

        public static IEnumerable<Assembly> FindAssemblies(Action<string> logFailure)
        {
            var assemblyPath = AppDomain.CurrentDomain.BaseDirectory;
            var binPath = FindBinPath();
            if (StringExtensions.IsNotEmpty(binPath))
            {
                assemblyPath = assemblyPath.AppendPath(binPath);
            }


            var files = new FileSystem().FindFiles(assemblyPath, FileSet.Deep("*.dll;*.exe"));
            foreach (var file in files)
            {
                var name = Path.GetFileNameWithoutExtension(file);
                Assembly assembly = null;

                try
                {
                    assembly = AppDomain.CurrentDomain.Load(name);
                }
                catch (Exception)
                {
                    logFailure(file);
                }

                if (assembly != null) yield return assembly;
            }
        }
开发者ID:kingreatwill,项目名称:fubumvc,代码行数:28,代码来源:AssemblyFinder.cs


示例17: copy_directory

        public void copy_directory()
        {
            var system = new FileSystem();

            system.ResetDirectory("dagobah");
            system.WriteStringToFile("dagobah".AppendPath("f1", "a.txt"), "something");
            system.WriteStringToFile("dagobah".AppendPath("f2", "a.txt"), "something");
            system.WriteStringToFile("dagobah".AppendPath("f3", "a.txt"), "something");
            system.WriteStringToFile("dagobah".AppendPath("f1", "f1a", "a.txt"), "something");
            system.WriteStringToFile("dagobah".AppendPath("f1", "f1a", "f1b", "a.txt"), "something");
            system.WriteStringToFile("dagobah".AppendPath("a.txt"), "something");

            system.DeleteDirectory("rhenvar");
            system.Copy("dagobah", "rhenvar");

            system.FindFiles("rhenvar", FileSet.Everything()).Select(x => x.PathRelativeTo("rhenvar")).OrderBy(x => x)
                .ShouldHaveTheSameElementsAs(
                    "a.txt",
                    FileSystem.Combine("f1", "a.txt"),
                    FileSystem.Combine("f1", "f1a", "a.txt"),
                    FileSystem.Combine("f1", "f1a", "f1b", "a.txt"),
                    FileSystem.Combine("f2", "a.txt"),
                    FileSystem.Combine("f3", "a.txt")
                );
        }
开发者ID:bobpace,项目名称:fubucore,代码行数:25,代码来源:FileSystemTester.cs


示例18: TearDown

        public void TearDown()
        {
            var fileSystem = new FileSystem();
            fileSystem.DeleteDirectory(theCodeDir);

            RippleFileSystem.Live();
        }
开发者ID:ventaur,项目名称:ripple,代码行数:7,代码来源:RippleFileSystemTester.cs


示例19: AssemblyInfo

 public AssemblyInfo(CodeFile codeFile, CsProjFile projFile)
 {
     _codeFile = codeFile;
     _projFile = projFile;
     this._fileSystem = new FileSystem();
     this.Initialize();
 }
开发者ID:awelburn,项目名称:FubuCsProjFile,代码行数:7,代码来源:AssemblyInfo.cs


示例20: SetUp

        public void SetUp()
        {
            var system = new FileSystem();
            system.DeleteDirectory("geonosis");
            system.CreateDirectory("geonosis");

            var data1 = newData();
            var data2 = newData();
            var data3 = newData();
            var data4 = newData();
            var data5 = newData();
            var data6 = newData();
            var data7 = newData();

            saveData(data1, "a", "a1");
            saveData(data2, "a", "a2");
            saveData(data3, "b", "b3");
            saveData(data4, "b", "b4");
            saveData(data5, "c", "c5");
            saveData(data6, "c", "c6");
            saveData(data7, "c", "c7");

            var data8 = newData();
            data8["pak1"] = "pak1-value";
            PackageSettingsSource.WriteToDirectory(data8, "geonosis".AppendPath("a"));

            theCache = new PackageFilesCache();
            theCache.AddDirectory(FileSystem.Combine("geonosis", "a"));
            theCache.AddDirectory(FileSystem.Combine("geonosis", "b"));
            theCache.AddDirectory(FileSystem.Combine("geonosis", "c"));
        }
开发者ID:jemacom,项目名称:fubumvc,代码行数:31,代码来源:PackageFilesIntegrationTester.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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