本文整理汇总了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);
}
示例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);
}
示例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;
}
示例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));
}
示例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"));
}
示例6: Setup
public virtual void Setup()
{
_latestRecentBackupQuery = A.Fake<LatestRecentBackupQuery>();
_fileSystem = A.Fake<FileSystem>();
_defaultSettings = new BackupSettings { BackupTargetDestination = "TargetDestination" };
}
示例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());
});
});
}
示例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();
}
示例9: FileSystemIntegrationTester
public FileSystemIntegrationTester()
{
_testDirectory = new TestDirectory();
_testDirectory.ChangeDirectory();
_fileSystem = new FileSystem();
_basePath = Path.GetTempPath();
}
示例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();
}
示例11: before_each
public void before_each()
{
_command = new NewCommand();
_fileSystem = new FileSystem();
_zipService = new ZipFileService(_fileSystem);
_commandInput = new NewCommandInput();
}
示例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));
}
示例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);
}
示例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());
});
});
}
示例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);
});
}