2012-10-27 66 views
1

我想开发一个网站,使用vb.net和asp.net与Visual Studio 2008的文件上传和下载选项。任何人都可以帮助我如何提供设施将文件上传到服务器,然后下载链接可供普通用户从服务器下载文件。提前致谢。文件上传/下载使用vb.net

回答

1

您可以使用asp:FileUpload控件上载文件到您的服务器,有权限的位置写入文件

这就像把控制你的.aspx一样简单文件

<asp:FileUpload runat="server" ID="MyFileUpload" /> 

代码隐藏

If (MyFileUpload.HasFile) Then 
    MyFileUpload.SaveAs('the full path to directory ' & filename) 

End If 

可以在数据库中的文件描述存储与他们的路径,你的页面,并显示检索该用户

您也可以浏览目录,并列出你的网页

上的文件
+0

谢谢你这么多它真的帮助了我。 – barsan

-1

昏暗FileToCopy作为字符串

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