本文整理汇总了C#中System.IO.FileInfo.Delete方法的典型用法代码示例。如果您正苦于以下问题:C# System.IO.FileInfo.Delete方法的具体用法?C# System.IO.FileInfo.Delete怎么用?C# System.IO.FileInfo.Delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.FileInfo
的用法示例。
在下文中一共展示了System.IO.FileInfo.Delete方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SingleCaptureJPGAndSendFTP
public void SingleCaptureJPGAndSendFTP(string ftphost,string username,string password)
{
try
{
ftp = new FtpClient(ftphost,username,password);
nameOfFile = string.Format( "{0}.{1}.{2} - {3}.{4}.{5}.jpg", DateTime.Now.Year,
DateTime.Now.Month.ToString().PadLeft(2,'0'),
DateTime.Now.Day.ToString().PadLeft(2,'0'),
DateTime.Now.Hour.ToString().PadLeft(2,'0'),
DateTime.Now.Minute.ToString().PadLeft(2,'0'),
DateTime.Now.Second.ToString().PadLeft(2,'0'));
//capture a JPG
//System.Drawing.Image fileImage = (System.Drawing.Image)ScreenCapturing.GetDesktopWindowCaptureAsBitmap();
System.Drawing.Image fileImage = (System.Drawing.Image)CaptureScreen.GetDesktopImage();
fileImage.Save( this.nameOfFile , System.Drawing.Imaging.ImageFormat.Jpeg );
//send a JPG to FTP Server
ftp.Login();
this.CreateFolder();
ftp.Upload(nameOfFile);
ftp.Close();
System.IO.FileInfo file = new System.IO.FileInfo(this.nameOfFile);
file.Delete();
}
catch {}
finally
{
GC.Collect();
}
}
示例2: Delete
// DELETE /api/music/5
public HttpResponseMessage Delete(Guid id)
{
HttpResponseMessage response = new HttpResponseMessage();
string filePath = HttpContext.Current.Server.MapPath("~/Content/Music") + "\\" + id.ToString() + ".mp3";
if (System.IO.File.Exists(filePath))
{
System.IO.FileInfo fi = new System.IO.FileInfo(filePath);
try
{
fi.Delete();
response.StatusCode = System.Net.HttpStatusCode.OK;
//Hreinsum cacheið
HttpContext.Current.Cache.Remove("songlist");
}
catch (System.IO.IOException e)
{
response.StatusCode = System.Net.HttpStatusCode.Unauthorized;
}
}
else
{
response.StatusCode = System.Net.HttpStatusCode.NotFound;
}
return response;
}
示例3: DeteleFile
/// <summary>
/// 删除文件
/// </summary>
/// <param name="path">路径</param>
public void DeteleFile(string path)
{
path = System.Web.HttpContext.Current.Server.MapPath("~" + path);
System.IO.FileInfo file = new System.IO.FileInfo(path);
if (file.Exists)
{
file.Delete();
}
}
示例4: DeleteConfirmed
public ActionResult DeleteConfirmed(int id)
{
Banner banner = db.Banners.Find(id);
System.IO.FileInfo fi = new System.IO.FileInfo(Server.MapPath(banner.Img));
fi.Delete();
db.Banners.Remove(banner);
db.SaveChanges();
return RedirectToAction("Index");
}
示例5: Main
static void Main(string[] args)
{
//try {
System.IO.FileInfo fi = new System.IO.FileInfo("somefile");
fi.Delete();
Console.WriteLine("Calling Delete() did not throw");
//} catch (System.IO.IOException e) {
//Console.WriteLine(e.Message);
//}
}
示例6: Delete
public void Delete(string fileName)
{
var prefix = fileName.Substring(0, 2);
var file = new System.IO.FileInfo(System.IO.Path.Combine(this.RootPath, prefix, fileName));
if (file.Exists)
{
file.Delete();
}
}
示例7: Delete
public void Delete(string path)
{
System.IO.FileInfo fi = new System.IO.FileInfo(path);
try
{
fi.Delete();
}
catch (System.IO.IOException e)
{
}
}
示例8: DeleteFile
/// <summary>
/// 删除文件文件或图片
/// </summary>
/// <param name="path">当前文件的路径 </param>
/// <returns>是否删除成功 </returns>
public void DeleteFile(string path)
{
path = Server.MapPath(path);
//获得文件对象
System.IO.FileInfo file = new System.IO.FileInfo(path);
if (file.Exists)
{
file.Delete();//删除
}
//file.Create();//文件创建方法
}
示例9: DeleteFile
private bool DeleteFile(string path, HttpContext context)
{
bool ret = false;
System.IO.FileInfo file = new System.IO.FileInfo(context.Server.MapPath(path));
if (file.Exists)
{
file.Delete();
ret = true;
}
return ret;
}
示例10: CreateTempFile
private void CreateTempFile(string content)
{
testFile = new System.IO.FileInfo("webdriver.tmp");
if (testFile.Exists)
{
testFile.Delete();
}
System.IO.StreamWriter testFileWriter = testFile.CreateText();
testFileWriter.WriteLine(content);
testFileWriter.Close();
}
示例11: Delete
public override int Delete(long ID)
{
string path = BuildFilePath(ID);
System.IO.FileInfo fi = new System.IO.FileInfo(path);
if (fi.Exists) {
fi.Delete();
return 1;
}
return 0;
}
示例12: SaveAsOfficeOpenXml
public void SaveAsOfficeOpenXml(string fileName)
{
System.IO.FileInfo fileInfo = new System.IO.FileInfo(fileName);
if (fileInfo.Exists)
fileInfo.Delete();
ExcelPackage excelPackage = new ExcelPackage(fileInfo);
ExcelWorksheet sheet1 = excelPackage.Workbook.Worksheets.Add("Sheet1");
for (int rowInd= 0; rowInd <rows.Count; rowInd++)
for (int colInd= 0; colInd<rows[rowInd].Cells.Count; colInd++)
sheet1.Cells[rowInd+1, colInd+1].Value = rows[rowInd].Cells[colInd].Value;
excelPackage.Save();
}
示例13: fileDelete
/// <summary>
/// 删除
/// </summary>
/// <param name="fileName"></param>
public bool fileDelete(string fileName)
{
string filePath = getFileFullPath(fileName);
System.IO.FileInfo fileInfo = new System.IO.FileInfo(filePath);
if (fileInfo.Exists == true)
{
fileInfo.Delete();
return true;
}
else
{
_errorMessage = "文件不存在";
return false;
}
}
示例14: ShouldBeAbleToAlterTheContentsOfAFileUploadInputElement
public void ShouldBeAbleToAlterTheContentsOfAFileUploadInputElement()
{
driver.Url = formsPage;
IWebElement uploadElement = driver.FindElement(By.Id("upload"));
Assert.IsTrue(string.IsNullOrEmpty(uploadElement.GetAttribute("value")));
System.IO.FileInfo inputFile = new System.IO.FileInfo("test.txt");
System.IO.StreamWriter inputFileWriter = inputFile.CreateText();
inputFileWriter.WriteLine("Hello world");
inputFileWriter.Close();
uploadElement.SendKeys(inputFile.FullName);
System.IO.FileInfo outputFile = new System.IO.FileInfo(uploadElement.GetAttribute("value"));
Assert.AreEqual(inputFile.Name, outputFile.Name);
inputFile.Delete();
}
示例15: btn_move_Click
protected void btn_move_Click(object sender, EventArgs e)
{
for (int i = 0; i < GridView2.Rows.Count; i++)
{
CheckBox cb = new CheckBox();
cb = (CheckBox)GridView2.Rows[i].FindControl("cbSel");
if (cb.Checked)
{
string name = GridView2.DataKeys[i].Value.ToString().Substring(GridView2.DataKeys[i].Value.ToString().LastIndexOf("/") + 1).ToUpper();
CY.HotelBooking.Core.Business.Web_Xml xml = new CY.HotelBooking.Core.Business.Web_Xml();
string webPath = Server.MapPath("~/ADIMG/");
System.IO.FileInfo file = new System.IO.FileInfo(webPath + name);
file.Delete();
xml.DeleteElement(webPath, "~/ADIMG/" + name);
}
}
string tablename = IMGType.SelectedItem.Value;
dataBind(tablename);
GridView2.DataBind();
}