Asp.net 使用vb.net上传/下载文件
我正试图开发一个网站与文件上传和下载选项使用vb.net和asp.net与Visual Studio 2008。有谁能帮我介绍一下如何将文件上传到服务器,然后普通用户可以使用下载链接从服务器下载文件。提前感谢。您可以使用Asp.net 使用vb.net上传/下载文件,asp.net,vb.net,file-upload,Asp.net,Vb.net,File Upload,我正试图开发一个网站与文件上传和下载选项使用vb.net和asp.net与Visual Studio 2008。有谁能帮我介绍一下如何将文件上传到服务器,然后普通用户可以使用下载链接从服务器下载文件。提前感谢。您可以使用asp:FileUpload控件将文件上载到您的服务器,这是一个具有写入文件权限的位置 只需将控件放入.aspx文件中即可 <asp:FileUpload runat="server" ID="MyFileUpload" /> 您可以将文件描述及其路径存储在
asp:FileUpload
控件将文件上载到您的服务器,这是一个具有写入文件权限的位置
.aspx
文件中即可
<asp:FileUpload runat="server" ID="MyFileUpload" />
您可以将文件描述及其路径存储在数据库中,在页面上检索并显示给用户
您还可以浏览目录并列出页面上的文件使用文件上载控件。
下面是一个上传的示例(用c#):
将文件变暗以字符串形式复制
FileToCopy = "F:\fd_demo_limits.swf"
Dim filenameTest = System.IO.Path.GetFileName(FileToCopy)
Dim path As String = "E:\"
Dim filename As String = "communicate.png"
Dim file_ As New System.IO.FileInfo(path + filename)
Dim file_ContentLength As String = "900000" ' check file Length file_.Length = 833740
If (file_.Length > file_ContentLength) Then
MsgBox("file length is large")
Exit Sub
End If
Dim allow_send_pic() As String = {".jpg", ".png", ".gif", "ico", ".png"}
Dim Extension As String = System.IO.Path.GetExtension(filename)
If Array.IndexOf(allow_send_pic, Extension.ToLower()) = -1 Then
MsgBox("File extension not valid")
Exit Sub
End If
If System.IO.File.Exists(FileToCopy) = True Then
While (System.IO.File.Exists(path + filename))
filename = "Copy of " + filename
End While
System.IO.File.Copy(FileToCopy, path + filename)
MsgBox("File Copied")
End If
非常感谢你,它真的帮助了我。
FileToCopy = "F:\fd_demo_limits.swf"
Dim filenameTest = System.IO.Path.GetFileName(FileToCopy)
Dim path As String = "E:\"
Dim filename As String = "communicate.png"
Dim file_ As New System.IO.FileInfo(path + filename)
Dim file_ContentLength As String = "900000" ' check file Length file_.Length = 833740
If (file_.Length > file_ContentLength) Then
MsgBox("file length is large")
Exit Sub
End If
Dim allow_send_pic() As String = {".jpg", ".png", ".gif", "ico", ".png"}
Dim Extension As String = System.IO.Path.GetExtension(filename)
If Array.IndexOf(allow_send_pic, Extension.ToLower()) = -1 Then
MsgBox("File extension not valid")
Exit Sub
End If
If System.IO.File.Exists(FileToCopy) = True Then
While (System.IO.File.Exists(path + filename))
filename = "Copy of " + filename
End While
System.IO.File.Copy(FileToCopy, path + filename)
MsgBox("File Copied")
End If