Click here to Skip to main content
15,662,426 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
download and upload file code using vb.net?
Posted
Comments
Sunasara Imdadhusen 29-Jan-11 4:07am    
Please describe your requirement in detail.
Sunasara Imdadhusen 29-Jan-11 4:08am    
Do you want to Upload and Download file functionality in ASP.Net using VB.Net code?

This is cool:
Silverlight 4 Drag and Drop File Manager[^]

BTW: Searching[^] is always a good idea ...

Regards
Espen Harlinn
 
Share this answer
 
Hi,

File Upload
VB
If FileUpload1.PostedFile.ContentLength > 0  Then
    Dim file As String = Server.MapPath("UploadedFiles/" & PostedFile.FileName);
    FileUpload1.SaveAs(file);
End If


File Download
VB
Public Shared Sub DownloadFile(FileName As String)
    If File.Exists(FileName) Then
        Dim strFileName As String = Path.GetFileName(FileName).Replace(" ", "%20")
        HttpContext.Current.Response.ContentType = "application/octet-stream"
        HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" & strFileName)
        HttpContext.Current.Response.Clear()
        HttpContext.Current.Response.WriteFile(FileName)
        HttpContext.Current.Response.[End]()
    End If
End Sub


Thanks,
Imadhusen
 
Share this answer
 
v2
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900