Copy Code code as follows:
protected void ReadFile ()/Read folder, file
{
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] + "<br/>");
//}
Response.Write ("Directorys count:" + directorys.length + "<br/>---------<br >");
string[] Files = directory.getfiles (Abssavepath + @ "" + Page.User.Identity.Name, "*");
Outstring. Append ("<ul>");
for (int i = 0; i < files.length; i++)
{
if (Path.getfilename (files[i])!= "Thumbs.db")
{
Outstring. Append ("<li> <br/><input type=/"checkbox/" value=/"common/" + path.getfilename (files[i)) + "/" name=/picname/"onclick=/" Getpicid ();/"id=/" Imgid "+ i.tostring () +"/"/><label for=/" Imgid "+ i.tostring () +"/">" + path.getfilename (Fi Les[i]) + "</label></li>");
}
}
Outstring. Append ("</ul>");
Response.Write (outstring. ToString ());
}
deleting files
string[] Strpicname = request["Imgids"]. Split (new char[] {', '});
for (int i = 0; i < Strpicname. Length; i++)
{
File.delete (Server.MapPath (strpicname[i). ToString ()));
}
Copy Code code as follows:
Looping through check boxes
<script language= "javascript" type= "Text/javascript" defer= "defer" >
var imgnum = document.getelementsbytagname ("input");
var imgids = "";
function Getpicid ()
{
document.getElementById ("Hidimgid"). Value = "";
for (Var i=0;i{
if (Imgnum[i].type = "checkbox" && imgnum[i].name = = "Picname" && imgnum[i].checked)
{
Imgids + = Imgids = = ""? Imgnum[i].value: "," + imgnum[i].value;
}
}
document.getElementById ("Hidimgid"). Value = Imgids;
}
</script>