本文整理汇总了C#中System.IO.FileSystem.DeleteFile方法的典型用法代码示例。如果您正苦于以下问题:C# FileSystem.DeleteFile方法的具体用法?C# FileSystem.DeleteFile怎么用?C# FileSystem.DeleteFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.FileSystem
的用法示例。
在下文中一共展示了FileSystem.DeleteFile方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExtractTo
public void ExtractTo(string description, Stream stream, string folder)
{
Console.WriteLine("Writing contents of zip file {0} to {1}", description, folder);
if (Directory.Exists(folder))
{
Directory.Delete(folder, true);
}
Directory.CreateDirectory(folder);
var system = new FileSystem();
string fileName = Path.GetTempFileName();
system.WriteStreamToFile(fileName, stream);
using (var zipFile = new ZipFile(fileName))
{
zipFile.ExtractAll(folder, ExtractExistingFileAction.OverwriteSilently);
}
system.DeleteFile(fileName);
}
示例2: ExplodeTo
public IPackage ExplodeTo(string directory)
{
var explodedDirectory = ExplodedDirectory(directory);
RippleLog.Info("Exploding to " + explodedDirectory);
var fileSystem = new FileSystem();
fileSystem.CreateDirectory(explodedDirectory);
fileSystem.ForceClean(explodedDirectory);
var package = new ZipPackage(_path);
package.GetFiles().Each(file =>
{
var target = explodedDirectory.AppendPath(file.Path);
fileSystem.CreateDirectory(target.ParentDirectory());
using (var stream = new FileStream(target, FileMode.Create, FileAccess.Write))
{
file.GetStream().CopyTo(stream);
}
});
fileSystem.CopyToDirectory(_path, explodedDirectory);
fileSystem.DeleteFile(_path);
var newFile = Path.Combine(explodedDirectory, Path.GetFileName(_path));
return new ZipPackage(newFile);
}
示例3: DoDelete
private void DoDelete(int subID, int locid)
{
FileSystem fs = new FileSystem(m_ident);
//Take results
Results resultda = new Results(m_ident);
Result.ResultList ress = GetResults(subID);
foreach (Result res in ress)
resultda.Delete(res.ID);
//Take any tests queued
AutoJobs jobda = new AutoJobs(m_ident);
AutoJobTest.AutoJobTestList tests = jobda.GetSubTests(subID);
foreach (AutoJobTest test in tests)
jobda.FinishTest(test);
//Take the submission record
m_dp.DeleteSubmission(subID);
//Take the files
CFile subdir = fs.GetFile(locid);
if (subdir != null)
fs.DeleteFile(subdir);
}
示例4: Delete
/// <summary>
/// Delete the assignment
/// </summary>
public bool Delete(int asstID)
{
FileSystem fs = new FileSystem(m_ident);
Submissions subda = new Submissions(m_ident);
Evaluations evalda = new Evaluations(m_ident);
Results resultda = new Results(m_ident);
Groups groupda = new Groups(m_ident);
AutoJobs jobda = new AutoJobs(m_ident);
Assignment asst = GetInfo(asstID);
//Check permission
Authorize(asst.CourseID, "delete", asstID, null);
//Take auto jobs
IProviderTransaction tran = m_dp.BeginTransaction();
AutoJob.AutoJobList jobs = GetAutoJobs(asstID, tran);
foreach (AutoJob job in jobs)
jobda.Finish(job.ID, tran);
m_dp.CommitTransaction(tran);
//Take submissions and results
Components.Submission.SubmissionList allsubs = GetSubmissions(asstID);
foreach (Components.Submission sub in allsubs)
subda.Delete(sub.ID);
//Take rubric
Rubric rub = GetRubric(asstID);
new Rubrics(m_ident).Delete(rub.ID);
//Take evaluations
Evaluation.EvaluationList allevals = GetEvals(asstID);
foreach (Evaluation eval in allevals)
evalda.Delete(eval.ID);
//Take groups
Group.GroupList groups = GetGroups(asstID);
foreach (Group group in groups)
groupda.Delete(group.PrincipalID, asstID);
//Take assignment
m_dp.DeleteAssignment(asstID);
//Take content
CFile content = fs.GetFile(asst.ContentID);
fs.DeleteFile(content);
//Log
Log("Deleted assignment: " + asst.Description, asst.ID);
return true;
}
示例5: tb_Delete
private bool tb_Delete(object sender, EventArgs e)
{
TreeNode node;
int ty = GetNodeType(node = GetCurrentNode());
switch (ty) {
case USER:
try {
new Courses(Globals.CurrentIdentity).RemoveUser(
node.NodeData.Split(" ".ToCharArray())[1], GetCourseID());
} catch (DataAccessException er) {
PageError(er.Message);
} catch (FileOperationException er) {
PageError(er.Message);
}
break;
case USERSUB:
try {
int subID = Convert.ToInt32(node.NodeData.Split(" ".ToCharArray())[2]);
new Submissions(Globals.CurrentIdentity).Delete(subID);
} catch (DataAccessException er) {
PageError(er.Message);
} catch (FileOperationException er) {
PageError(er.Message);
}
break;
case ASSIGNMENT:
try {
new Assignments(Globals.CurrentIdentity).Delete(GetNodeIndex(node));
} catch (DataAccessException er) {
PageError(er.Message);
} catch (FileOperationException er) {
PageError(er.Message);
}
break;
case ANNOUNCEMENT:
try {
new Announcements(Globals.CurrentIdentity).Delete(GetNodeIndex(node));
} catch (DataAccessException er) {
PageError(er.Message);
}
break;
case SECTION:
try {
new Sections(Globals.CurrentIdentity).Delete(GetNodeIndex(node));
} catch (DataAccessException er) {
PageError(er.Message);
}
break;
case HEADING:
case CANNED:
case AUTOMATIC:
Rubric rub = new Rubrics(Globals.CurrentIdentity).GetInfo(GetNodeIndex(node));
if (rub.ParentID < 0)
PageError("Cannot delete the root rubric");
else {
try {
new Rubrics(Globals.CurrentIdentity).Delete(rub.ID);
} catch (DataAccessException er) {
PageError(er.Message);
} catch (FileOperationException er) {
PageError(er.Message);
}
}
break;
case FOLDER:
case DOCUMENT:
FileSystem fs = new FileSystem(Globals.CurrentIdentity);
CFile file = fs.GetFile(GetNodeIndex(node));
try {
fs.DeleteFile(file);
} catch (DataAccessException er) {
PageError(er.Message);
} catch (FileOperationException er) {
PageError(er.Message);
}
break;
}
LoadNode((TreeNode)node.Parent);
ActivateNodeView((TreeNode)node.Parent);
return true;
}