Question

I am writing a software and I used MSDN's FTP file download code to download a file from the FTP server. The problem is that the file hence downloaded, is corrupt and when opened with MS Access, asks for a password. To resolve this, I have two options: "Find a way to correctly download the file." OR "Directly change the file on the ftp server."

I found the latter to be better and I can't figure a way out. I don't have any bit of code I've tried as I don't have ANY idea.

Any help is appreciated.

Code for FTp

Dim request As FtpWebRequest = DirectCast(WebRequest.Create("ftp://admin:123456@192.168.14.155/database.accdb"), FtpWebRequest)
    request.Method = WebRequestMethods.Ftp.DownloadFile

    'request.Credentials = New NetworkCredential("admin", "123456")

    Dim response As FtpWebResponse = DirectCast(request.GetResponse(), FtpWebResponse)

    Dim responseStream As Stream = response.GetResponseStream
    Dim reader As New StreamReader(responseStream)

    Using writer As New StreamWriter(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "/database.accdb")
        writer.Write(reader.ReadToEnd)
    End Using

    reader.Close()
    response.Close()

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top