C# 文件操作(上传 下载 删除 文件列表...)
来源:互联网 发布:一元抢购软件 编辑:程序博客网 时间:2024/05/16 10:23
using System.IO;
如下要点:
HTML部分:
- <form id="form1" runat="server" method="post" enctype="multipart/form-data">
- <input id="FileUpLoad" type="file" runat="server"/><br />
- string strFileFullName = System.IO.Path.GetFileName(this.FileUpLoad.PostedFile.FileName);
- this.FileUpLoad.PostedFile.SaveAs(Server.MapPath("./xmlzip/") + trFileFullName);
----------
ListBox的SelectedIndexChanged事件 设定相关下载连接
protected void lst_DownLoadFileList_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
string strJS = "window.open('xmlzip/";
strJS += this.lst_DownLoadFileList.SelectedItem.Text.Trim();
strJS += "'); return false; ";
this.imgbtn_DownLoadFile.Attributes.Add("onclick", strJS);
}
catch (Exception ex)
{
ex.ToString();
}
this.Label1.Text = "<a href=/"xmlzip/a.rar/">a.rar</a>"
3.文件删除
---------
string strFilePath = 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");
}
}
4.得到文件夹下的文件列表
-----------
#region 得到当前可用的文件列表
/// <summary>
/// 得到当前可用的文件列表
/// </summary>
/// <param name="IsAlert">是否需要弹出提示信息</param>
private void fn_getCurrFileList(bool IsAlert)
{
try
{
//查找xmlzip文件夹下 属于其本身UnitCoding的相关zip文件
string strXmlZipDirectory = Server.MapPath("../xmlzip/");
if (Directory.Exists(strXmlZipDirectory))
{
- C# 文件操作(上传 下载 删除 文件列表...)
- C# 文件操作(上传 下载 删除 文件列表...)
- C# 文件操作(上传 下载 删除 文件列表...)
- C# 文件操作(上传 下载 删除 文件列表...)
- C# 文件操作(上传 下载 删除 文件列表...)
- C# 文件操作(上传 下载 删除 文件列表...)(转)
- C# 文件操作(上传 下载 删除 文件列表...)
- C# 文件操作(上传 下载 删除 文件列表...)
- C# 文件操作(上传 下载 删除 文件列表...)
- C# 文件操作(上传 下载 删除 文件列表)
- C# 文件操作(上传 下载 删除 文件列表...)
- C#实现Ftp各种操作(上传,下载,删除文件,创建目录,删除目录,获得文件列表)
- C# 上传文件到指定目录,单击下载文件,删除指定目录文件,打开文件列表
- net,C#,Ftp各种操作,上传,下载,删除文件,创建目录,删除目录,获得文件列表
- .net,C#,Ftp各种操作,上传,下载,删除文件,创建目录,删除目录,获得文件列表...
- .net,C#,Ftp各种操作,上传,下载,删除文件,创建目录,删除目录,获得文件列表
- C#,Ftp各种操作,上传,下载,删除文件,创建目录,删除目录,获得文件列表
- .net,C#,Ftp各种操作,上传,下载,删除文件,创建目录,删除目录,获得文件列表...
- [编程实例]Dev-C++编写动态调用dll杀进程的程序
- SQL递归处理数据
- VC++工程的文件组织
- MPLAYER播放电影很慢
- Linux之PPP初探
- C# 文件操作(上传 下载 删除 文件列表...)
- C++虚函数表解析(转)
- xml字符串中的变成了<和>,这怎么办呢
- 中文字符集简介(GB2312 GB13000(GBK) GB18030)
- C++各大有名库的介绍之C++标准库
- 有一个关于手机的想法
- Eclipse中如何修改properties等文件的编码?
- GridView绑定时间的问题
- Eclipse安装插件