upload.aspx.vb
来自「是可以运行的电子光盘 有程序与PPT介绍 对于学习VB。NET的有参考意义」· VB 代码 · 共 67 行
VB
67 行
Imports System.io
Imports Data
Imports FileDirServer
Partial Class FileManager_Upload
Inherits WebDiskBasePage
Private CurrentPath As String
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Me.IsPostBack Then
txtpath.Text = FileDirServer.ShowMapPath(Session("UserDir"))
Else
Me.StatusMessage.Text = String.Empty
End If
End Sub
Protected Sub Upload_Click(ByVal sender As Object, ByVal e As EventArgs)
CurrentPath = Session("CurrentPath")
' Process only if a file has been specified
If (UploadedFile.PostedFile.ContentLength > 0) Then
If Not Directory.Exists(CurrentPath) Then
StatusMessage.Text = CurrentPath & "用户目录不存在"
Return
Else
Dim dirLen As Long = GetDirectorySize(CurrentPath)
Dim LoginType As Data.LoginType
LoginType = Session("LoginType")
If LoginType = Data.LoginType.SUPUERMANAGER Then '管理员
If dirLen > Data.C_LargeManagerDir Then
StatusMessage.Text = "管理员用户最大目录限为" & FormatSize(Data.C_LargeManagerDir)
Return
End If
Else
If dirLen > Data.C_LargeUseDir Then
StatusMessage.Text = "一般用户最大目录限为" & FormatSize(Data.C_LargeUseDir)
Return
End If
End If
End If
Dim fileName As String = Path.Combine(CurrentPath, Path.GetFileName(UploadedFile.PostedFile.FileName))
Try
' Save to the current directory
If File.Exists(fileName) Then
StatusMessage.Text = "要上载的文件已经存在,请删除或更换文件名后再上载"
Return
Else
UploadedFile.PostedFile.SaveAs(fileName)
' Refresh the page
End If
Catch ex As Exception
End Try
Response.Redirect("MainFile.aspx?Folder=" & Server.UrlEncode(CurrentPath))
Else
StatusMessage.Text = "要上载的文件不存在或文件长度为0字节"
Return
End If
End Sub
End Class
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?