Var myobj = document.getlementByid (CurrentLoadingID "Expend"); // Get a node's expansion point picture object
Var myicon = document.getlementByid (CurrentLoadingID "icon"); // Get the icon object of the node
Var mainobj = document.getlementByid (currentloadingID); // Get the text object of the node
// Expand the node of the specified number of tree list, if the child node of the node is not loaded, loaded
Var myobj = document.getlementByid (Strid "Expend"); // Get the expansion point picture object of the node
Var myicon = document.getlementByid (Strid "icon"); // Get the icon object of the node
Its CS source code is
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;
Namespace fileview
{
///
/// Return to a list of files, single file information, and files all content
///
/// You can any reference to all code to modify and reference all code, you can use unrestricted systems that are used in any nature.
///
/ / / But please respect the intellectual property rights during use, I hope that when I have modified it.
///
// / Do not tamper or delete such an intellectual property statement of poor Baba
///
/// Nanjing Yuan Yongfu 2004-8-8
/// YYF9989@hotmail.com
/// summary>
Public class fileview: system.web.ui.page
{
Private static string c_basepath = "d: //"; // Initialization folder path
Private const string c_list = "list"; // Returns the parameters of the file list
Private const string c_get = "get"; // Get parameters for file information
Private const string c_getfile = "getfile"; // Get parameters for file content
Private const string c_preview = "preview"; // Get the preview result of the picture
Private static string str refviewtype = "list";
// Type list of document content
Private static system.collections.specialized.namevalueCollection mycontenttypelist = null;
/ / Save the list of full path names for files and directories
Static system.collections.ArrayList myfilelist = new arraylist ();
///
/// Setting, return to initialization root directory
/// summary>
Public Static String Basepath
{
Get {returnif c_basepath;}
set
{
C_BasePath = Value;
MyFileList.clear ();
}
Private Void Page_Load (Object Sender, System.EventArgs E)
{
/ / Place the user code here to initialize the page
String strpath = NULL;
String straType = NULL;
// Initialization document type list
IF (MyContentTypelist == NULL)
{
MyContentTypelist = new system.collections.specialized.namevalueCollection ();
MyContentTypelist.Add ("JS", "Text");
MyContentTypelist.Add ("JSP", "Text");
MyContentTypelist.Add ("ASP", "Text");
MyContentTypelist.Add ("TXT", "Text");
MyContentTypelist.Add ("CPP", "Text");
MyContentTypelist.Add ("C", "Text");
MyContentTypelist.Add ("H", "Text");
MyContentTypelist.Add ("frm", "text");
MyContentTypelist.Add ("SQL", "Text");
MyContentTypelist.Add ("CS", "text");
MyContentTypelist.Add ("VB", "Text");
MyContentTypelist.Add ("CLS", "text");
MyContentTypelist.Add ("Java", "Text");
MyContentTypelist.Add ("ini", "text");
MyContentTypelist.Add ("resx", "text / xml");
MyContentTypelist.Add ("XML", "Text / XML");
MyContentTypelist.Add ("XSD", "Text / XML");
MyContentTypelist.Add ("XSL", "Text / XML");
MyContentTypelist.Add ("BMP", "Image / BMP");
MyContentTypelist.Add ("JPG", "Image / JPEG");
MyContentTypelist.Add ("JPEG", "Image / JPEG");
MyContentTypelist.Add ("TIFF", "Image / Tiff");
MyContentTypelist.Add ("PNG", "Image / PNG"); MyContentTypelist.Add ("GIF", "Image / GIF");
MyContentTypelist.Add ("ICO", "Image / X-icon");
MyContentTypelist.Add ("DOC", "Application / Msword");
MyContentTypelist.Add ("XLS", "Application / X-msexcel");
MyContentTypelist.Add ("PPT", "Application / X-MspowerPoint");
MyContentTypelist.Add ("Zip", "Application / X-Zip-compressed");
}
// Analyze parameters, get object numbers and parameter types
IF (this.Request ["ViewType"]! = null)
{
StrviewType = this.Request ["ViewType"];
Return;
}
INDEX = TOINT32VALUE (this.Request ["id"], - 1);
Strtype = this.Request ["type"];
IF (c_list == stroyal)
{
// Get a list of files
IF (Index <0 || index> myfilelist.count - 1)
{
MyFileList.clear ();
StrPath = c_basepath;
}
Else
{
StrPath = (string) MyFileList [index];
}
/ / Generate an XML document list of a list of descriptors
System.xml.xmldocument mydoc = new system.xml.xmldocument ();
MyDoc.loadxml ("");
MyDoc.documentelement.settribute ("text", system.io.path.getFileName (StrPath));
MyDoc.documentelement.setttribute ("ViewType", StrviewType);
IF ((System.IO.File.GetaTributes (strpath) & system.io.fileAttributes.directory! = 0)
{
String [] strfiles = system.io.directory.GetFileSystemNuthTries (strpath, "*. *");
For (int icount = 0; icount
{
System.xml.xmlelement myelement = mydoc.createElement ("file");
MyDoc.documentelement.appendchild (myelement);
Try
{
MyElement.setttribute ("text", system.io.path.getFileName (Strfiles [iCount])); MyElement.setttribute ("id", myfilelist.count.tostring ());
IF ((STRFILES [ICOUNT) & System.IO.FileAttributes.directory) == 0)
{
// This path is a file
String strfileext = system.io.path.Getextension (strfiles [iCount]);
IF (StrfileExt! = null && strfileext.length> 0)
{
StrfileExt = strfileext.substring (1);
StrfileExt = strfileext.trim ();
// Set the icon of the file
IF (strfileext == "iCO")
MyElement.setttribute ("img", "fileview.aspx? type = getfile =" myfilelist.count.toString ());
Else
{
IF (System.IO.FILE.EXISTS (this.mappath (") " // " StrfileExt " .bmp "))
MyElement.setttribute ("IMG", StrfileExt ".bmp");
}
MyElement.setttribute ("Type", StrfileExt;
}
/ / Set the tree list link URL
// If you are displayed directly, it is displayed directly, otherwise you will use XSL format.
String strcontenttype = myContentTypelist.get (StrfileExt.tolower ());
IF (strContentType! = NULL
&& ("Image /") || StrContentType.StartSwith ("Text"))))
{
MyElement.setttribute ("href", "fileview.aspx? type = getfile" myfilelist.count.toString ());
IF (strcontenttype.startswith ("image /"))
MyElement.setttribute ("IMGFILE", "1");
}
Else
MyElement.setttribute ("href", "fileview.aspx? id =" myfilelist.count.toString ());
MyElement.setttribute ("File", "1");
MyElement.setttribute ("size", (new system.io.fileinfo (Strfiles [iCount])). Length.toString ());
}
Else
{
// This path is a directory
MyElement.setttribute ("Childlist", "FileView.aspx? type = list & id =" myfilelist.count.tostring ()); myelement.setttribute ("file", "0");
}
System.datetime DTMDATE = system.io.file.getlastaccesstime (Strfiles [iCount]);
MyElement.setttribute ("Accesstime", DTMDATE.TOSTRING ("YYYY-MM-DD HH: MM: SS"));
/ / Add a project to the object path list
myfilelist.add (strfiles [iCount]);
}
Catch (Exception EXT)
{
MyElement.setttribute ("Text", "Error:" ext.Message);
Break;
}
}
}
// Output file list document
THIS.RESPONSE.CONTENTENCODING = system.text.Encoding.Getencoding (936);
THIS.RESPONSE.WRITE (" XML Version = /" 1.0 / "encoding = /" gb2312 / "?> Xml-stylesheet type = /" text / xsl / "href = /" htmlcontent.xml / "? > ");
This.Response.write (MyDoc.documentelement.outerxml);
//mydoc.save (this.Response.output);
}
ELSE IF (c_getfile == stroyal)
{// return file content
IF (INDEX> = 0 && index
{
String strfile = (string) MyFileList [index];
IF ((System.IO.File.GetaTributes & System.io.fileAttributes.directory) == 0)
{
IF (System.IO.File.exists (Strfile))
{
String strfileext = getfileextension (strfile);
String strcontenttype = myContentTypelist.get (strfileext);
IF (this.Request ["preview"]! = null)
{
IF (strcontenttype.startswith ("image /"))
{
Using (System.drawing.Image MyImg = System.drawing.Image.FromFile (Strfile))
{
IF (MyImg.Width <100)
This.Response.writefile (STRFILE);
Else
{
System.drawing.Image preimg = myimg.getthumbnailImage (100, 100, null, system.intptr.zero);
Preimg.save (this.Response.OutputStream, System.drawing.Imaging.imageFormat.jpeg); preImg.dispose ();
}
}
}
Return;
}
Else
{
IF (strContentType == Null || strcontenttype.length == 0)
This.Response.writefile (STRFILE);
Else
{
IF (strContentType == "text")
{
THIS.RESPONSE.CONTENTENCODING = system.text.Encoding.Getencoding (936);
This.Response.contenttype = "text / html";
This.Response.write ("
");
This.Response.writefile (STRFILE);
This.Response.write (" pre>");
Return;
}
Else
{
This.Response.contenttype = strcontenttype;
This.Response.writefile (STRFILE);
}
}
}
}
}
}
}
Else IF (c_preview == startpe)
{
}
Else
{
// Return to file information
IF (INDEX> = 0 && index
{
System.xml.xmldocument mydoc = new system.xml.xmldocument ();
MyDoc.loadxml ("");
MyDoc.documentelement.settribute ("type", getfileextension (string) MyFileList [index]))
MyDoc.documentelement.setattribute ("URL", "FileView.aspx? type = getfile =" index.toString ());
THIS.RESPONSE.WRITE (" XML Version = /" 1.0 / "encoding = /" gb2312 / "?> Xml-stylesheet type = /" text / xsl / "href = /" htmlcontent.xml / "? > ");
This.Response.write (MyDoc.documentelement.outerxml);
}
}
}
///
/// obtain a file extension according to the path
/// summary>
/// file path param>
/// file extension, if there is no extension, return blank string returns>
Private string getfileextension (String Strfile)
{
Try
{
String strfileext = system.io.path.Getextension (strfile);
StrfileExt = strfileext.substring (1) .trim (). TOLOWER (); Return StrfileExT;
}
Catch
{
""; "
}
}
///
/// Convert the string into an integer, return to the default value if the conversion fails
/// summary>
/// string param>
/// Default param>
/// Conversion Results returns>
Private int toint32value (String strdata, int defaultValue)
{
Try
{
IF (strData == null)
Return DefaultValue;
Else
Return Convert.TOINT32 (STRDATA);
}
Catch
{
Return DefaultValue;
}
}
#Region web form designer generated code
Override protected void oninit (Eventargs E)
{
//
// Codegen: This call is necessary for the ASP.NET Web Form Designer.
//
InitializationComponent ();
Base.onit (E);
}
///
/// Designer supports the required method - do not use the code editor to modify
/// This method is content.
/// summary>
Private vidinitiRizeComponent ()
{
This.Load = New System.EventHandler (this.page_load);
}
#ndregion
}
}
Document HTMLCONTENT.XML content
XML Version = "1.0" encoding = "UTF-8"?>
Used to process the XML file describing the single file information, generate an HTML page code that actually displays the document
You can freely refer to modifying and reference all of the code, you can use unrestricted systems that are unrestricted in any nature.
But please respect the intellectual property rights during use, I hope that when I have revised it.
Please don't tell or delete such an intellectual property statement of poor Baba.
Nanjing Yuan Yongfu 2004-8-8
YYF9989@hotmail.com
->
[ Set preview view mode ]
xsl: attribute>
xsl: attribute>
xsl: attribute>
img>
xsl: for-energy>
xsl: if>
Style = "Border-Color: # cc0066; width: 100%; Border-Collapse: Collapse; Z-Index: 101; Left: 40px; font-family: Song; Font-Size: 12px">
>
file name td>
| Size TD>
| Type TD>
| Modification time td>
TR>
Currently calculate the code of the current node ->
xsl: when>
xsl: when>
xsl: choose>
XSL: Variable>
|
xsl: when>
close.bmp xsl: when>
xsl: attribute>
xsl: if>
td>
|
td>
|
td>
|
td>
TR>
xsl: for-energy>
TABLE>
xsl: if>
body>
html>
xsl: when>
hEAD>
This document is a flash animation, will play with FALSH animation player
Please confirm your computer system installed Flash animation player
div>
xsl: attribute>
param>
|