Copy codeThe Code is as follows:
Protected void ReadFile () // read the 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 (Files [I]) + "</label> </li> ");
}
}
Outstring. Append ("</ul> ");
Response. Write (outstring. ToString ());
}
// Delete an object
String [] strpicname = Request ["imgids"]. Split (new char [] {','});
For (int I = 0; I <strpicname. Length; I ++)
{
File. Delete (Server. MapPath (strpicname [I]. ToString ()));
}
Copy codeThe Code is as follows:
// Check box for loop Traversal
<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>