ファイル名を取得する簡単な方法はありますか?
はい
Dim fileName As String = System.IO.Path.GetFileName(e.filename)
以下は、Excel ファイルのみが許可されている完全なサンプルです。
Private Shared allowedExtensions As New List(Of String)(New String() {".xls", ".xlsx"})
Private ASPxUploadControl1_FileUploadComplete(ByVal sender As Object, ByVal e As AjaxControlToolkit.AsyncFileUploadEventArgs) ASPxUploadControl1.FileUploadComplete
If e.state = AjaxControlToolkit.AsyncFileUploadState.Success Then
Dim fileExtension As String = System.IO.Path.GetExtension(e.filename)
If allowedExtensions.Contains(fileExt) Then
Dim fileName As String = System.IO.Path.GetFileName(e.filename)
Dim appDir As String = Hosting.HostingEnvironment.ApplicationPhysicalPath
Dim subDir As String = My.Settings.UploadSubDirectory
Dim path As String = appDir & subDir & fileName
ASPxUploadControl1.PostedFile.SaveAs(path)
ASPxUploadControl1.FileContent.Close()
End If
End If
End Sub