本文整理汇总了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);
}
示例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);
}
}
示例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);
}
}
}
}
示例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);
}
示例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);
}
示例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);
}
示例7: LuxConfigHost
public LuxConfigHost(IInternalConfigHost internalConfigHost)
{
FileSystem = new FileSystem();
if (ConfigSystemProxy.FileSystem != null)
FileSystem = ConfigSystemProxy.FileSystem;
Host = internalConfigHost;
}
示例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);
}
示例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);
}
}
示例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);
}
示例11: serviceConfiguration
private static BottleServiceConfiguration serviceConfiguration()
{
var directory = BottlesServicePackageFacility.GetApplicationDirectory();
var fileSystem = new FileSystem();
return fileSystem.LoadFromFile<BottleServiceConfiguration>(directory, BottleServiceConfiguration.FILE);
}
示例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)));
}
示例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);
}
示例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;
}
示例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());
});
}