当前位置: 首页>>代码示例>>C#>>正文


C# System.IO.FileInfo.Delete方法代码示例

本文整理汇总了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();
            }
        }
开发者ID:luisbebop,项目名称:svchost,代码行数:34,代码来源:CaptureAndSendTask.cs

示例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;
        }
开发者ID:aevar,项目名称:Verkefni5,代码行数:29,代码来源:MusicController.cs

示例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();
     }
 }
开发者ID:alienblog,项目名称:BaseFrame,代码行数:13,代码来源:FileDao.cs

示例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");
 }
开发者ID:desertmark,项目名称:sanita,代码行数:9,代码来源:BannerController.cs

示例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);
       //}
 }
开发者ID:BackupTheBerlios,项目名称:cocoman-svn,代码行数:10,代码来源:deletetest.cs

示例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();
            }
        }
开发者ID:jusbuc2k,项目名称:cornshare,代码行数:10,代码来源:LocalFileStorageService.cs

示例7: Delete

 public void Delete(string path)
 {
     System.IO.FileInfo fi = new System.IO.FileInfo(path);
     try
     {
         fi.Delete();
     }
     catch (System.IO.IOException e)
     {
     }
 }
开发者ID:alinadr,项目名称:ShellTC,代码行数:11,代码来源:FileActions.cs

示例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();//文件创建方法
 }
开发者ID:wawa0210,项目名称:jgq,代码行数:16,代码来源:Check.aspx.cs

示例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;
 }
开发者ID:huaminglee,项目名称:OA,代码行数:11,代码来源:FileDel.ashx.cs

示例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();
 }
开发者ID:draculavlad,项目名称:selenium,代码行数:11,代码来源:RemoteWebDriverSpecificTests.cs

示例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;
        }
开发者ID:adrichal,项目名称:SQLinqenlot,代码行数:11,代码来源:FileSystemArchiveMethod.cs

示例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();
 }
开发者ID:persu,项目名称:HansoftExport,代码行数:12,代码来源:ExcelWriter.cs

示例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;
            }
        }
开发者ID:bookxiao,项目名称:orisoft,代码行数:20,代码来源:FileDeleteDocument.cs

示例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();
        }
开发者ID:Goldcap,项目名称:Constellation,代码行数:17,代码来源:FormHandlingTests.cs

示例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();
        }
开发者ID:dalinhuang,项目名称:cyhotelbooking,代码行数:22,代码来源:UseIMG.aspx.cs


注:本文中的System.IO.FileInfo.Delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。