各位高手帮忙,我的项目里边有个文件夹“test”,我的文件都上传到这个文件夹下了,我有什么办法可以获取到这个文件夹下的所有文件,并且让它们在页面显示出来(供我删除,或下载)【asp.net】
先谢了!
先谢了!
解决方案 »
- jquery高手帮忙
- 怎么写api整合接口
- 提交修改数据库,当时数据库里没有变化,请指点!
- DataGrid里点一行(点行的任何地方),取出这行的数据~大家帮帮我
- 请问各位编asp.net程序时,是用vs.net编,还是用dreamweaver,两者怎样配合使用,谢谢!
- 问问
- 求助----如何重命名一个目录
- 简单问题:如何在asp中格式化输出数据?
- 我在项目的一个的子目录中设置web.config出现“配置错误”。。。
- 求"<OBJECT id=WebBrowser classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 width=0></OBJECT>"的說明文檔。
- 经典笔试题疑问?产生一个int数组,长度为100,并向其中随机插入1-100,并且不能重复。
- 大家都是怎么处理并发操作的???
{
WebUI.isLogin();
if (!IsPostBack)
{
BindDDLAccess(); //绑定文件名
}
}
public void BindDDLAccess()
{
System.IO.DirectoryInfo info = new System.IO.DirectoryInfo(System.Web.HttpContext.Current.Server.MapPath("~/Copy/")); System.IO.FileInfo[] aa = info.GetFiles(); for (int i = 0; i < aa.Length; i++)
{
Regex re = new Regex(@"\w*\.\w*");
string st = re.Match(aa[i].FullName).Value.ToString();
int num = i;
this.ddlAccess.Items.Insert(i, new ListItem(st, i.ToString()));
}
this.ddlAccess.Items.Insert(0, "--请选择--");
} protected void btnAdd_Click(object sender, EventArgs e)
{
string backupPath = urlconvertorlocal("/Copy/") + this.ddlAccess.SelectedItem.Text.ToString();
string sourcePath = urlconvertorlocal("/App_Data/HDZS.mdb");
string message = Recover(backupPath, sourcePath);
WebUI.Alert(message, this.Page);
} /// <summary>
/// 恢复Access数据库
/// </summary>
/// <param name="backupPath">备份数据库绝对路径</param>
/// <param name="sourcePath">当前数据库绝对路径</param>
public string Recover(string backupPath, string sourcePath)
{
if (!File.Exists(backupPath))
{
return "备份数据库不存在!";
}
try
{
File.Copy(backupPath, sourcePath, true);
return "恢复成功!";
}
catch (IOException ixp)
{
throw new Exception(ixp.ToString());
} } /// <summary>
/// 删除指定文件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnDel_Click(object sender, EventArgs e)
{ System.IO.FileInfo file = new System.IO.FileInfo(urlconvertorlocal("/Copy/") + this.ddlAccess.SelectedItem.Text.ToString());
if (!file.Exists)
{
WebUI.Alert("文件不存在!", this.Page);
}
else
{
file.Delete();
WebUI.AlertAndRedirect("删除成功!", "Edit_Access.aspx", this.Page);
}
}
/// <summary>
/// 转换为绝对路径
/// </summary>
/// <param name="imagesurl1"></param>
/// <returns></returns>
private string urlconvertorlocal(string imagesurl1)
{ string tmpRootDir = Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString());//获取程序根目录 string imagesurl2 = tmpRootDir + imagesurl1.Replace(@"/", @"\"); //转换成绝对路径 return imagesurl2; }http://blog.csdn.net/ws297636199/archive/2010/11/04/5987170.aspx
比着葫芦画瓢。