📄 disk_index.aspx.vb
字号:
Imports System.IO
Imports System.Security
Imports System.Xml
Public Class index1
Inherits System.Web.UI.Page
#Region " Web 窗体设计器生成的代码 "
'该调用是 Web 窗体设计器所必需的。
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Protected WithEvents Header As System.Web.UI.WebControls.Label
Protected WithEvents UpBtn As System.Web.UI.WebControls.ImageButton
Protected WithEvents GoRoot As System.Web.UI.WebControls.ImageButton
Protected WithEvents FilesFolders As System.Web.UI.WebControls.PlaceHolder
Protected WithEvents UploadBtn As System.Web.UI.WebControls.Button
Protected WithEvents NewFileText As System.Web.UI.WebControls.TextBox
Protected WithEvents NewFileBtn As System.Web.UI.WebControls.Button
Protected WithEvents NewFolderText As System.Web.UI.WebControls.TextBox
Protected WithEvents NewFolderBtn As System.Web.UI.WebControls.Button
Protected WithEvents setRootTxt As System.Web.UI.WebControls.TextBox
Protected WithEvents setRootBtn As System.Web.UI.WebControls.Button
Protected WithEvents fileToUpload As System.Web.UI.HtmlControls.HtmlInputFile
'注意: 以下占位符声明是 Web 窗体设计器所必需的。
'不要删除或移动它。
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: 此方法调用是 Web 窗体设计器所必需的
'不要使用代码编辑器修改它。
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'在此处放置初始化页的用户代码
' the current directory is stored in Ssession("Path"), if it isn't set, set it to /
If Session("Path") = "" Or Session("Path").ToString() = "" Then
Session("Path") = "/" 'default is root directory
End If
If Session("Path").ToString() <> "/" Then
Header.Text = "Showing contents of <b>" + Session("Path").ToString() + "</b> directory."
Else
Header.Text = "Showing contents of <B>root directory.</b>"
UpBtn.Visible = False ' this button has no context in the root dir
GoRoot.Visible = False ' same
End If
showFiles() ' list the files and folders in the current directory
End Sub
Public Function showFiles()
' safety checks handled by checkValidSessionPath function
DirectoryInfo(mainDir = checkValidSessionPath())
if mainDir = "" return ' bail out
Int(alternate = 0) 'used for alternating background color in table rows
foreach(DirectoryInfo d in mainDir.GetDirectories())
' build up some literal controls, and buttons for the row of the table representing the directory
Literal(dim newColumn1 as Literal = New Literal)
newColumn1.Text = "</td> <td> "
Literal(dim newColumn2 as Literal = New Literal)
newColumn2.Text = "</td> <td> "
Literal(dim newColumn3 as Literal = New Literal)
newColumn3.Text = "</td> <td>"
' display a folder icon
Literal(picColumn = New Literal)
if alternate mod 2 == 1 ' alternate back-colour of rows
picColumn.Text = "<TR><td><img src=pics/folder.gif></td><td>"
Else
picColumn.Text = "<TR bgcolor='#e8e8e8'><td><img src=pics/folder.gif></td><td>"
' this link changes the path to the directory being clicked
Dim changePathBtn As LinkButton = New LinkButton
changePathBtn.Text = d.Name.ToString()
changePathBtn.CommandArgument = d.Name.ToString()
changePathBtn.Command += New CommandEventHandler(ChangePath)
' this link deletes the directory, but it must be empty for the delete to be successful
HyperLink(deleteBtn = New HyperLink)
deleteBtn.ImageUrl = "pics/delete_icon.gif"
deleteBtn.NavigateUrl = "javascript:confirmDelete('delete.aspx?Type=Folder&Name=" + Server.UrlEncode(Session("Path").ToString() + d.Name.ToString()) + "','" + d.Name.ToString() + "');" ' use client-side confirm function for deleting
Literal(endRow = New Literal)
endRow.Text = "</td></tr>"
' add the controls to the container in the webform
FilesFolders.Controls.Add(picColumn)
FilesFolders.Controls.Add(changePathBtn)
FilesFolders.Controls.Add(newColumn1)
FilesFolders.Controls.Add(newColumn2)
FilesFolders.Controls.Add(newColumn3)
FilesFolders.Controls.Add(deleteBtn)
FilesFolders.Controls.Add(endRow)
alternate++ ' bump the int for back-colour alternation
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -