當前位置: 首頁>>代碼示例>>C#>>正文


C# IO.FileSystem類代碼示例

本文整理匯總了C#中System.IO.FileSystem的典型用法代碼示例。如果您正苦於以下問題:C# FileSystem類的具體用法?C# FileSystem怎麽用?C# FileSystem使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


FileSystem類屬於System.IO命名空間,在下文中一共展示了FileSystem類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的System.IO.FileSystem類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。