asp.net读取与删除磁盘文件的实例代码
本文导语: 分享一个实例: asp.net读取磁盘文件、删除实例代码。 代码: 代码示例: protected void ReadFile() //读取文件夹,文件 { string savePath = @"common"; StringBuilder outstring = new StringBuilder(); string ab...
分享一个实例:
asp.net读取磁盘文件、删除实例代码。
代码:
protected void ReadFile() //读取文件夹,文件
{
string savePath = @"common";
StringBuilder outstring = new StringBuilder();
string absSavePath = Server.MapPath(savePath);
string[] Directorys = Directory.GetDirectories(absSavePath + @"/" + Page.User.Identity.Name);
//for (int i = 0; i < Directorys.Length; i++)
//{
// Response.Write(Directorys[i] + "
");
//}
//Response.Write("Directorys count:" + Directorys.Length + "个
---------
");
string[] Files = Directory.GetFiles(absSavePath + @"" + Page.User.Identity.Name, "*");
outstring.Append("
- ");
" + Path.GetFileName(Files[i]) + " ");
for (int i = 0; i < Files.Length; i++)
{
if (Path.GetFileName(Files[i]) != "Thumbs.db")
{ // www.
outstring.Append("
}
}
outstring.Append("
Response.Write(outstring.ToString());
}
//删除文件
string[] strpicname = Request["imgids"].Split(new char[] { ',' });
for (int i = 0; i < strpicname.Length; i++)
{
File.Delete(Server.MapPath(strpicname[i].ToString()));
}
2,js代码
var imgnum = document.getElementsByTagName("input");
var imgids = "";
function getpicid()
{
document.getElementById("hidimgid").value = "";
for (var i=0;i