新聞中心
這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
C#文件列表操作四大重點(diǎn)
C#文件列表要點(diǎn)1:上傳文件

創(chuàng)新互聯(lián)建站服務(wù)項(xiàng)目包括鐵嶺網(wǎng)站建設(shè)、鐵嶺網(wǎng)站制作、鐵嶺網(wǎng)頁(yè)制作以及鐵嶺網(wǎng)絡(luò)營(yíng)銷策劃等。多年來(lái),我們專注于互聯(lián)網(wǎng)行業(yè),利用自身積累的技術(shù)優(yōu)勢(shì)、行業(yè)經(jīng)驗(yàn)、深度合作伙伴關(guān)系等,向廣大中小型企業(yè)、政府機(jī)構(gòu)等提供互聯(lián)網(wǎng)行業(yè)的解決方案,鐵嶺網(wǎng)站推廣取得了明顯的社會(huì)效益與經(jīng)濟(jì)效益。目前,我們服務(wù)的客戶以成都為中心已經(jīng)輻射到鐵嶺省份的部分城市,未來(lái)相信會(huì)繼續(xù)擴(kuò)大服務(wù)區(qū)域并繼續(xù)獲得客戶的支持與信任!
HTML部分:
- 〈 formid=\"form1\"runat=\"
- server\"method=\"post\"enctype=\
- "multipart/form-data\"〉
- 〈 inputid=\"FileUpLoad\"type=\"
- file\"runat=\"server\"/〉〈 br/〉
- 后臺(tái)CS部分按鈕事件
- //stringstrFileFullName=
- System.IO.Path.GetFileName(this.
- FileUpLoad.PostedFile.FileName);
- //this.FileUpLoad.PostedFile.SaveAs(Server.MapPath(
- \"./Xmlzip/\")+strFileFullName);
C#文件列表要點(diǎn)2.文件下載
- ListBox的SelectedIndexChanged事件設(shè)
- 定相關(guān)下載連接
- protectedvoidlst_DownLoadFileList
- _SelectedIndexChanged(objectsender,EventArgse)
- {
- try
- {
- stringstrJS=\"window.open(\'Xmlzip/\";
- strJS+=this.lst_DownLoadFileList.
- SelectedItem.Text.Trim();
- strJS+=\"\');returnfalse;\";
- this.imgbtn_DownLoadFile.Attributes.
- Add(\"onclick\",strJS);
- }
- catch(Exceptionex)
- {
- ex.ToString();
- }
- }
- 或者也可以通過(guò)改變Label的Text值來(lái)實(shí)現(xiàn)點(diǎn)擊
- 后實(shí)現(xiàn)文件下載的超級(jí)連接
- this.Label1.Text=\"〈 ahref=
- \\\"Xmlzip/a.rar\\\"〉a.rar〈 /a〉\"
C#文件列表要點(diǎn)3.文件刪除
- stringstrFilePath=Server.MapPath(
- \"../CountryFlowMgr/Xmlzip/\"+this.lst_
- DownLoadFileList.SelectedItem.Text.Trim());
- if(File.Exists(strFilePath))
- {
- File.Delete(strFilePath);
- if(File.Exists(strFilePath))
- {
- Response.Write(\"ok\");
- }
- else
- {
- Response.Write(\"ok\");
- }
- }
C#文件列表要點(diǎn)4.得到文件夾下的文件列表
- #region得到當(dāng)前可用的文件列表
- ///〈 summary〉
- ///得到當(dāng)前可用的文件列表
- ///〈 /summary〉
- ///〈 paramname=\"IsAlert\"〉
- 是否需要彈出提示信息〈 /param〉
- privatevoidfn_getCurrFileList(boolIsAlert)
- {
- try
- {
- //查找Xmlzip文件夾下屬于其本
- 身UnitCoding的相關(guān)zip文件
- stringstrXmlZipDirectory=
- Server.MapPath(\"../Xmlzip/\");
- if(Directory.Exists(strXmlZipDirectory))
- {
- //DirectoryInfodi=newDirectoryInfo(
- Environment.CurrentDirectory);
- DirectoryInfodi=newDirectoryInfo(
- strXmlZipDirectory);
- FileInfo[]FI=di.GetFiles(\"*.zip\"
- );//只查.zip文件
- if(FI.Length〉0)
- {
- lst_DownLoadFileList.Items.Clear();
- foreach(FileInfotmpFIinFI)
- {
- ListItemtmpItem=newListItem();
- tmpItem.Text=tmpFI.Name;
- lst_DownLoadFileList.Items.Add(tmpItem);
- }
- lst_DownLoadFileList.SelectedIndex=0;
- }
- else
- {
- if(IsAlert)
- {
- Response.write(\"查無(wú)可以下載的文件!\");
- }
- }
- }
- }
- catch(Exceptionex)
- {
- ex.ToString();
- }
- }
- #endregion
當(dāng)前題目:C#文件列表操作四大重點(diǎn)
網(wǎng)址分享:http://fisionsoft.com.cn/article/cdspghg.html


咨詢
建站咨詢
