ASP.net 里怎么对fileUpload控件上传的文件进行管理
来源:百度知道 编辑:UC知道 时间:2024/07/05 18:55:48
using System.IO;
protected void Page_Load(object sender, EventArgs e)
{if (!IsPostBack)
{
BindFileName();
}
}
public void BindFileName()
{
DropDownList1.Items.Clear();
string path = Server.MapPath("你的文件夹的路径");
DirectoryInfo di = new DirectoryInfo(path);
foreach (FileInfo fi in di.GetFiles())
{
ListItem li = new ListItem();
li.Value = fi.FullName;
li.Text = fi.Name;
DropDownList1.Items.Add(li);
}
}
//把文件夹里的文件名绑定到DropDownList1
protected void Button3_Click(object sender, EventArgs e)
{//这里是删除按钮
File.Delete(DropDownList1.SelectedValue);
BindFileName();
Response.Write("<script>alert('删除成功')</script>");
}
建立一个数据库
全部的操作都到数据库里面进行就可以了
用文件操作,完全