同桌上课用手指进去了好爽_欧美丰满熟妇xxⅹⅹ性大i_成人av天天日天天拍拍_猛男gay帅男gay男男同志_欧美va天堂在线观看_人妻无码av中文系列三里桃花_亚欧免费无码在线观看_久久久精品国产亚洲av水_日韩在线免费看污污污_2021无码专区人妻系列日韩

首頁 優(yōu)化推廣 ASP.NET對(duì)文件的操作,創(chuàng)建文件,判斷文件是否存在,判斷文件是否存在刪除文件夾

ASP.NET對(duì)文件的操作,創(chuàng)建文件,判斷文件是否存在,判斷文件是否存在刪除文件夾

來源: | 時(shí)間:2013/6/10 23:56:57 |

操作文件必須引入using System.IO;命名空間

 

      //獲取一個(gè)文件的大小         System.IO.FileInfo file = new System.IO.FileInfo("C:\\t.txt");         int fileSize = (int)file.Length / 1024;//把文件大小換算成KB         Response.Write("<script>alert(" + fileSize.ToString() + ");</script>");

-------------------------------------------------------------------------

-------創(chuàng)建文件夾using System.IO; private void button2_Click(object sender, EventArgs e)     {         if (Directory.Exists("\\picture"))//判斷一個(gè)文件夾是否存在         {             MessageBox.Show("directory exists");         }         else {

    //創(chuàng)建一個(gè)文件夾             Directory.CreateDirectory("\\picture");         }     }

Directory.Delete(path,true);//刪除一個(gè)文件夾,其中path是文件夾的絕對(duì)路徑

---------------------打開一個(gè)文件

Process.Start("C:\\t.txt");//打開一個(gè)文件

 

 

public void Page_Load(Object src,EventArgs e)   {       StreamWriter rw = File.CreateText(Server.MapPath(".")+"[url=file://mytext.txt/]\\myText.txt[/url]");       rw.WriteLine("追逐理想");       rw.WriteLine("kzlll");       rw.WriteLine(".NET筆記");       rw.Flush();       rw.Close();   } 打開文本文件 StreamReader sr = File.OpenText(Server.MapPath(".")+"[url=file://mytext.txt/]\\myText.txt[/url]");   StringBuilder output = new StringBuilder();   string rl;   while((rl=sr.ReadLine())!=null)   {   output.Append(rl+"<br>");   }   lblFile.Text = output.ToString();   sr.Close();  

C#追加文件 StreamWriter sw = File.AppendText(Server.MapPath(".")+"[url=file://mytext.txt/]\\myText.txt[/url]");      sw.WriteLine("追逐理想");        sw.WriteLine("kzlll");        sw.WriteLine(".NET筆記");        sw.Flush();        sw.Close();   C#拷貝文件          string OrignFile,NewFile;            OrignFile = Server.MapPath(".")+"[url=file://mytext.txt/]\\myText.txt[/url]";            NewFile = Server.MapPath(".")+"[url=file://mytextcopy.txt/]\\myTextCopy.txt[/url]";            File.Copy(OrignFile,NewFile,true);   C#刪除文件          string delFile = Server.MapPath(".")+"[url=file://mytextcopy.txt/]\\myTextCopy.txt[/url]";            File.Delete(delFile);   C#移動(dòng)文件        string OrignFile,NewFile;          OrignFile = Server.MapPath(".")+"[url=file://mytext.txt/]\\myText.txt[/url]";          NewFile = Server.MapPath(".")+"[url=file://mytextcopy.txt/]\\myTextCopy.txt[/url]";          File.Move(OrignFile,NewFile);   C#創(chuàng)建目錄              // 創(chuàng)建目錄c:\sixAge              DirectoryInfo d=Directory.CreateDirectory("c:\\sixAge");              // d1指向c:\sixAge\sixAge1              DirectoryInfo d1=d.CreateSubdirectory("sixAge1");              // d2指向c:\sixAge\sixAge1\sixAge1_1              DirectoryInfo d2=d1.CreateSubdirectory("sixAge1_1");              // 將當(dāng)前目錄設(shè)為c:\sixAge              Directory.SetCurrentDirectory("c:\\sixAge");              // 創(chuàng)建目錄c:\sixAge\sixAge2              Directory.CreateDirectory("sixAge2");              // 創(chuàng)建目錄c:\sixAge\sixAge2\sixAge2_1              Directory.CreateDirectory("sixAge2\\sixAge2_1"); 

服務(wù)熱線

153 8323 9821

功能和特性

價(jià)格和優(yōu)惠

網(wǎng)站和維護(hù)

推廣和優(yōu)化

微信服務(wù)號(hào)