c# 对文件的操作
上一篇 / 下一篇 2009-02-15 23:27:23 / 个人分类:软件开发相关
1208328177
- 自动化测试:
- 测试文档:
1/**//// <summary>51Testing软件测试网
M|(r8JB"S*A!?
2/// 获取文件列表
(cJ$x~-n.YC0 3/// </summary>
"L0u~ \-H{gjZ~0 4private void GetFileList()51Testing软件测试网0Z5jwE4S+R+Oq&}sw
5{
3`g{3e \y_U0 6 string strCurDir,FileName,FileExt;
#X/k6Ld)E a$h0 7 51Testing软件测试网(i0|K2]b
8 /**////文件大小
6c3M'm{8VD)I0JdhY0 9 long FileSize;51Testing软件测试网(~*X/A4XST|l
10
buT;dWN4H011 /**////最后修改时间;
Z(N}BR(j#l-L012 DateTime FileModify;51Testing软件测试网 t+lGM#o
13
$k {@u-wP+q Cs014 /**////初始化51Testing软件测试网5p7JQ,fgLZ
15 if(!IsPostBack)51Testing软件测试网5T\U6E A,L!GF#u
16 {
j8r%E4]E EK!Y017 /**////初始化时,默认为当前页面所在的目录51Testing软件测试网8l }/j rK Vs:e
18 strCurDir = Server.MapPath(".");
bS5b,iDv _g019 lblCurDir.Text = strCurDir;51Testing软件测试网UV k6D&ZvW wGJa
20 txtCurDir.Text = strCurDir;
z&n,x:D o a f1~Y021 }51Testing软件测试网;K3[2hN(NF
22 else51Testing软件测试网~,Q;s b1CHK2n7R
23 {
-f H.T$g4Ni#w4LP024 strCurDir = txtCurDir.Text;51Testing软件测试网am.]9We MWp
25 txtCurDir.Text = strCurDir;51Testing软件测试网`T})pl:E(J(u
26 lblCurDir.Text = strCurDir;
e'k _ s&ZS4C027 }51Testing软件测试网5l1xk/Eo:}_3v$]$rv
28 FileInfo fi;51Testing软件测试网 bt l,b+]
29 DirectoryInfo dir;51Testing软件测试网T eHu)I7N8k
30 TableCell td;51Testing软件测试网4[$S|T$uh8g
31 TableRow tr;
J/VH3QSI G-m032 tr = new TableRow();
2F^5B:g/vd!h033 51Testing软件测试网'OKrvY9xt@%s^n
34 /**////动态添加单元格内容
XV,G&tb}B:z{CFe6m035 td = new TableCell();
Cdt%? e.B'a036 td.Controls.Add(new LiteralControl("文件名"));51Testing软件测试网3UJf/A3l l
37 tr.Cells.Add(td);
*\k%iw'\8p038 td = new TableCell();51Testing软件测试网vB GpFqJ)tm
39 td.Controls.Add(new LiteralControl("文件类型"));
}$Qi1l? hG%M040 tr.Cells.Add(td);51Testing软件测试网+x"H3p~;ar f
41 td = new TableCell();51Testing软件测试网k h JBD(MD
42 td.Controls.Add(new LiteralControl("文件大小"));51Testing软件测试网 O+tW{(K_u`^
43 tr.Cells.Add(td);
2/// 获取文件列表
(cJ$x~-n.YC0 3/// </summary>
"L0u~ \-H{gjZ~0 4private void GetFileList()51Testing软件测试网0Z5jwE4S+R+Oq&}sw
5{
3`g{3e \y_U0 6 string strCurDir,FileName,FileExt;
#X/k6Ld)E a$h0 7 51Testing软件测试网(i0|K2]b
8 /**////文件大小
6c3M'm{8VD)I0JdhY0 9 long FileSize;51Testing软件测试网(~*X/A4XST|l
10
buT;dWN4H011 /**////最后修改时间;
Z(N}BR(j#l-L012 DateTime FileModify;51Testing软件测试网 t+lGM#o
13
$k {@u-wP+q Cs014 /**////初始化51Testing软件测试网5p7JQ,fgLZ
15 if(!IsPostBack)51Testing软件测试网5T\U6E A,L!GF#u
16 {
j8r%E4]E EK!Y017 /**////初始化时,默认为当前页面所在的目录51Testing软件测试网8l }/j rK Vs:e
18 strCurDir = Server.MapPath(".");
bS5b,iDv _g019 lblCurDir.Text = strCurDir;51Testing软件测试网UV k6D&ZvW wGJa
20 txtCurDir.Text = strCurDir;
z&n,x:D o a f1~Y021 }51Testing软件测试网;K3[2hN(NF
22 else51Testing软件测试网~,Q;s b1CHK2n7R
23 {
-f H.T$g4Ni#w4LP024 strCurDir = txtCurDir.Text;51Testing软件测试网am.]9We MWp
25 txtCurDir.Text = strCurDir;51Testing软件测试网`T})pl:E(J(u
26 lblCurDir.Text = strCurDir;
e'k _ s&ZS4C027 }51Testing软件测试网5l1xk/Eo:}_3v$]$rv
28 FileInfo fi;51Testing软件测试网 bt l,b+]
29 DirectoryInfo dir;51Testing软件测试网T eHu)I7N8k
30 TableCell td;51Testing软件测试网4[$S|T$uh8g
31 TableRow tr;
J/VH3QSI G-m032 tr = new TableRow();
2F^5B:g/vd!h033 51Testing软件测试网'OKrvY9xt@%s^n
34 /**////动态添加单元格内容
XV,G&tb}B:z{CFe6m035 td = new TableCell();
Cdt%? e.B'a036 td.Controls.Add(new LiteralControl("文件名"));51Testing软件测试网3UJf/A3l l
37 tr.Cells.Add(td);
*\k%iw'\8p038 td = new TableCell();51Testing软件测试网vB GpFqJ)tm
39 td.Controls.Add(new LiteralControl("文件类型"));
}$Qi1l? hG%M040 tr.Cells.Add(td);51Testing软件测试网+x"H3p~;ar f
41 td = new TableCell();51Testing软件测试网k h JBD(MD
42 td.Controls.Add(new LiteralControl("文件大小"));51Testing软件测试网 O+tW{(K_u`^
43 tr.Cells.Add(td);