vb.net download file from FTP
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 1 of 1

Thread: vb.net download file from FTP

  1. #1
    Join Date
    Jan 2009
    Posts
    154

    vb.net download file from FTP

    I have the following code:

    Code:
    Dim FileName as string="ABC.csv"
    My.Computer.Network.DownloadFile("ftp://nec_stage.tradenex.com/IN/" + FileName, "C:\" + FileName, "nec_stage", "password")
    
                Dim TargetFile As New System.IO.FileInfo(Directory + FileName)
    
                Response.Clear()
    
                Response.AddHeader("Content-Disposition", "attachment; filename=" + TargetFile.Name)
    
                Response.AddHeader("Content-Length", TargetFile.Length.ToString())
    
                Response.ContentType = "application/octet-stream"
    
                Response.WriteFile(TargetFile.FullName)
    
                Response.End()
    The code works. However, the above code will first download the file from FTP to C:\, then only read the file and let the user to choose which path they want the file to be save. Is there anyway to direct get the file from FTP and let the user choose which path to save without save it to C:\ first.


    This is because I get the following error when I trying to save the file to C:\ first.

    ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.
    Last edited by daniel50096230; November 9th, 2009 at 10:07 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center