如何在VB.NET中上传文件? [英] How to upload file in VB.NET?
本文介绍了如何在VB.NET中上传文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在vb.net Windows应用程序中上传文件,请帮助我
抱歉,这是File而不是Excel File
How to upload file in vb.net windows application please help me
Sorry guys it is File not Excel File
推荐答案
My.Computer.Network.UploadFile
否则这可能对您有帮助:
^ ]
How aboutMy.Computer.Network.UploadFile
Or this may be helpful to you:
An FTP client library for .NET 2.0[^]
用于从Excel上传数据到数据库,请看这里:
链接1 [链接2 [
For uploading data from Excel to database, look here:
Link 1[^]
Link 2[^]
If needed more, just Google it!
只需执行以下操作即可:
Just do this simply :
<pre lang="vb">If (Not File1.PostedFile Is Nothing) _
And (File1.PostedFile.ContentLength > 0) Then
''determine file name
Dim sFileName As String = _
System.IO.Path.GetFileName(File1.PostedFile.FileName)
Try
If File1.PostedFile.ContentLength <= lMaxFileSize Then
''save file on disk
File1.PostedFile.SaveAs(sFileDir + sFileName)
lblMessage.Visible = True
lblMessage.Text = "File: " + sFileDir + sFileName + _
" Uploaded Successfully"
Else ''reject file
lblMessage.Visible = True
lblMessage.Text = "File Size if Over the Limit of " + _
lMaxFileSize
End If
Catch exc As Exception ''in case of an error
lblMessage.Visible = True
lblMessage.Text = "An Error Occured. Please Try Again!"
DeleteFile(sFileDir + sFileName)
End Try
Else
lblMessage.Visible = True
lblMessage.Text = "Nothing to upload. Please Try Again!"
End If
好吧,File1是一些用于处理文件上载或打开的控件.找到它.
Well, File1 is some control that handle file upload or open. Find it.
这篇关于如何在VB.NET中上传文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文