本文整理汇总了C#中FileSystem.DeleteFile方法的典型用法代码示例。如果您正苦于以下问题:C# FileSystem.DeleteFile方法的具体用法?C# FileSystem.DeleteFile怎么用?C# FileSystem.DeleteFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileSystem
的用法示例。
在下文中一共展示了FileSystem.DeleteFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: TeardownEnvironment
public void TeardownEnvironment()
{
_application.Teardown();
var fileSystem = new FileSystem();
fileSystem.DeleteFile("pak1.zip");
fileSystem.DeleteFile("pak2.zip");
fileSystem.DeleteFile("pak3.zip");
}
示例3: 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);
}
示例4: Test_FileSystem_That_File_Delete_Removes_File
public void Test_FileSystem_That_File_Delete_Removes_File()
{
var fileSystem = new FileSystem();
var path = Path.Combine(TestContext.DeploymentDirectory, @"IO\1.txt");
fileSystem.DeleteFile(path);
Assert.IsFalse(fileSystem.FileExists(path));
// cleanup
using(fileSystem.OpenFile(path, FileMode.OpenOrCreate)) {; }
Assert.IsTrue(fileSystem.FileExists(path));
}
示例5: ExplodeTo
public IPackage ExplodeTo(string directory)
{
var explodedDirectory = directory.AppendPath(Name).ToFullPath();
RippleLog.Info("Exploding to " + explodedDirectory);
var fileSystem = new FileSystem();
fileSystem.CreateDirectory(explodedDirectory);
fileSystem.CleanDirectory(explodedDirectory);
fileSystem.DeleteFile(FileName);
fileSystem.WriteStringToFile(explodedDirectory.AppendPath(FileName), "");
return new StubPackage(Name, Version.ToString());
}
示例6: Check
public void Check(IPackageLog log)
{
var file = _folder.AppendPath(TracerFile);
try
{
var system = new FileSystem();
system.WriteStringToFile(file, "just a test of whether or not a process can write to a folder");
system.DeleteFile(file);
log.Trace(SuccessMessage.ToFormat(_folder));
}
catch (Exception)
{
log.MarkFailure(FailureMessage.ToFormat(_folder));
}
}
示例7: Delete
/// <summary>
/// Remove an auto evaluation (takes results with it)
/// </summary>
public bool Delete(int evalID)
{
Evaluation eval = GetInfo(evalID);
//take evaluation
m_dp.DeleteEval(evalID);
//Delete zone files
if (eval.Type == Evaluation.AUTO_TYPE) {
FileSystem fs = new FileSystem(m_ident);
AutoEvaluation aeval = eval as AutoEvaluation;
CFile zdir = fs.GetFile(aeval.ZoneID);
if (null != zdir)
fs.DeleteFile(zdir);
}
return true;
}
示例8: should_add_project_references
public void should_add_project_references()
{
// build it up through a stringbuilder to use the environment-specific newline
var solutionBuilder = new StringBuilder("Microsoft Visual Studio Solution File, Format Version 11.00")
.AppendLine()
.AppendLine("# Visual Studio 2010")
.AppendLine(@"Project(""{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"") = ""FubuMVC.StructureMap"", ""FubuMVC.StructureMap\FubuMVC.StructureMap.csproj"", ""{ABFEA520-820C-4B77-9015-6A09E24252FA}""")
.AppendLine("EndProject")
.AppendLine("Global")
.AppendLine(" GlobalSection(SolutionConfigurationPlatforms) = preSolution")
.AppendLine(" Debug|Any CPU = Debug|Any CPU")
.AppendLine(" Release|Any CPU = Release|Any CPU")
.AppendLine(" EndGlobalSection")
.AppendLine(" GlobalSection(SolutionProperties) = preSolution")
.AppendLine(" HideSolutionNode = FALSE")
.AppendLine(" EndGlobalSection")
.AppendLine("EndGlobal");
var system = new FileSystem();
var solutionFile = "tmp.sln";
system.AppendStringToFile(solutionFile, solutionBuilder.ToString());
var project = new CsProj
{
Name = "Test",
ProjectGuid = "123",
RelativePath = @"example1\example1.csproj"
};
var service = new SolutionFileService(system);
service.AddProject(solutionFile, project);
var solutionContents = system.ReadStringFromFile(solutionFile);
var lines = service.SplitSolution(solutionContents);
lines[4].ShouldEqual("Project(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \"Test\", \"example1\\example1.csproj\", \"{123}\"");
lines[5].ShouldEqual("EndProject");
system.DeleteFile(solutionFile);
}
示例9: GilesAssemblyFileOperation
private static void GilesAssemblyFileOperation(string testAssemblyFolder, FileOperationType fileOperationType)
{
var fileSystem = new FileSystem();
var filesToCopy = GetGilesAssembliesToUse();
var gilesTargetAssemblyFolder = Path.Combine(testAssemblyFolder, @"Giles");
if (!Directory.Exists(gilesTargetAssemblyFolder))
Directory.CreateDirectory(gilesTargetAssemblyFolder);
filesToCopy.Each(f =>
{
var sourcePath = f.Contains("\\") ? f : GetFileSourceLocation(f);
var targetPath = Path.Combine(gilesTargetAssemblyFolder, fileSystem.GetFileName(f));
if (fileOperationType == FileOperationType.Copy || fileOperationType == FileOperationType.Delete)
if (fileSystem.FileExists(targetPath))
fileSystem.DeleteFile(targetPath);
if (fileOperationType == FileOperationType.Copy)
{
fileSystem.CopyFile(sourcePath, targetPath);
}
});
}
示例10: SetMode
public void SetMode(string mode)
{
var fileSystem = new FileSystem();
string file = filename();
if (mode.IsEmpty())
{
fileSystem.DeleteFile(file);
}
else
{
fileSystem.WriteStringToFile(file, mode);
}
}
示例11: Clear
public static void Clear()
{
var fileSystem = new FileSystem();
string file = filename();
fileSystem.DeleteFile(file);
}
示例12: TeardownEnvironment
public override void TeardownEnvironment()
{
base.TeardownEnvironment();
var fileSystem = new FileSystem();
fileSystem.DeleteFile("pak1.zip");
fileSystem.DeleteFile("pak2.zip");
fileSystem.DeleteFile("pak3.zip");
fileSystem.DeleteFile("pak4.zip");
fileSystem.DeleteFile("spark.zip");
}
示例13: SetUp
public void SetUp()
{
theFileSystem = new FileSystem();
theFileSystem.DeleteDirectory("fake-app");
theFileSystem.CreateDirectory("fake-app");
theFileSystem.FindFiles(".".ToFullPath(), ApplicationSettings.FileSearch())
.Each(x => theFileSystem.DeleteFile(x));
theOriginalSettings = ApplicationSettings.For<KayakApplication>();
theOriginalSettings.ParentFolder = "fake-app".ToFullPath();
theOriginalSettings.Write();
aSpecificLocation = theOriginalSettings.GetFileName();
}
示例14: DeleteFileDeletesFile
public void DeleteFileDeletesFile()
{
var fileSystem = new FileSystem();
var fileName = Path.GetTempFileName();
try
{
File.WriteAllText(fileName, "Test");
fileSystem.DeleteFile(fileName);
Assert.IsFalse(File.Exists(fileName));
}
finally
{
CleanUpFile(fileName);
}
}
示例15: DeleteFileTest
public void DeleteFileTest()
{
FileSystem target = new FileSystem();
int fileId = 150;
string userEmail ="[email protected]";
string userPass = "pass2";
target.DeleteFile(fileId, userEmail, userPass);
}