asp: textbox>
asp: button>
p> form> ask: panel> asp: label>
asp: label>
ask: label>
asp: panel> body> html> .vbimports system.ioimports system.datapublic class Webform6 inherits system.web.ui.page
#REGON "Web フォ フォ ム デザ ナ ナ 生 れ れ コ コ ド"
'こ こ び し は Web フォ フォ ム デザ で で 必 必 必 必 必 必 必 必 必. ナ private subinitializecomponent ()
End Sub Protected WithEvents FileUploadForm As System.Web.UI.WebControls.Panel Protected WithEvents FileName As System.Web.UI.WebControls.Label Protected WithEvents FileLength As System.Web.UI.WebControls.Label Protected WithEvents FileType As System.Web.UI .WebControls.Label Protected WithEvents AnswerMsg As System.Web.UI.WebControls.Panel Protected WithEvents loFile As System.Web.UI.HtmlControls.HtmlInputFile Protected WithEvents Button1 As System.Web.UI.WebControls.Button Protected WithEvents dir As System.Web .UI.WebControls.TextBox
'メモ: の プレ プレ ス ホ ホ ダ Declaration は Web フォ フォ ム デザ で で 必 必 必 必 必 必 必 必. 'Removing および および および し で.. Private DesignerPlaceHolderDeclaration as System.Object
Private Sub Page_init (Byval e as system.Object, byval e as system.eventargs) Handles mybase.init 'codegen: こ こ メソ ド ド び し フォ 必 必 必 必 す 必 必 必 必 必 す. ナ. ナ ナ.. ナ ナ ナ ナ ナ ナ 必 デザ ナ 必 必 ナ 必 デザ デザ 必 ナ デザ 必 ナ ナ ナ ナ ナ デザ 必 必 必 必 必 必 必 必 デザ 必 必 必 必 必 必 必 必 デザ デザ す す 必 デザ デザ デザ デザ デザ デザ デザ デザ デザ. デザ デザ デザ デザ デザ デザ デザ デザ デザ デザ デザ'コ コ ド ド エディ っ っ て 変 変.. くだ くだ くだ くだ くだ い っ くだ くだ い い くだ いInitializationComponent () End Sub
#End region
Private sub page_load (byval sender as system.Object, byval e as system.eventargs) Handles mybase.load 'ペ ペ ジ を 初 化 化 ユ ユ ザ ザ コ ド を ここ に し ま ま. ま ユ ユ ユ ユ ユ ユ ユ ユ ユ ユ ユ ユ ユ ユ ユ ユ ユ ユ ユ ユ ユ ユ ユ ユ ユ ユ ユ ユEnd Sub
Private Sub Button1_Click (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim lstrFileName As String Dim lstrFileNamePath As String Dim lstrFileFolder As StringIf dir.Text <> "" Then 'If upload directory is empty, Use "C: /" as the default upload directory lstrfilefolder = dir.text 'get uploaded to the server name else lstrfilefolder = "c: /" end if
Dim files as system.web.httpfilecollection = system.web.httpContext.current.request.files Dim PostedFile as system.Web.httppostedFile = files (0)
Lstrfilename = system.io.path.GetFileName (PostedFile.FileName) 'gets the file name' Note: Lofile.postedFile.FileName Returns the file name selected by the file dialog box, which contains the file directory information
lstrfilename = path.getFileName (lstrfilename) 'Remove directory information, return to file name
If Directory.exists (lstrfilefolder)) THEN 'determines whether the upload directory exists, there is no existence to establish Directory.createdIRectory (LSTRFILDER) end if
LstrfileNamePath = LSTRFILEFOLDER & LSTRFILENAME 'Upload files to server Lofile.postedFile.saveas (lstrfilenamepath)' Get upload directory and file name
'Obtains and displays the upload properties FileName.Text = lstrFileName' FileType.Text = loFile.PostedFile.ContentType obtained file name 'type file obtained FileLength.Text = CStr (loFile.PostedFile.ContentLength)' get file length FileUploadForm.Visible = False answermsg.visible = true 'Display upload file properties
End Sub
END CLASS