0 votes

When I download a file via ftp, the file remains in use.

using (Ftp client = new Ftp())
{
    client.ServerCertificateValidate += ValidateCertificate;
    client.Connect(adress);
    client.AuthTLS();
    client.Login(username, pass);

    foreach (FtpItem item in client.GetList())
    {
        if (item.Name == "database.sqlite")
        {
            client.Download(
                @"database.sqlite", 
                @"database\" + tanim + "_database.sqlite");
        }
    }
    client.Close();
 }
by (200 points)
edited by

1 Answer

0 votes

After downloading a file, Ftp.dll closes the file and doesn't use it anymore.

Please verify which exact application is using the file. You can use Process Explorer for that purpose. Can it be an Antivirus app for example?

Does closing your application fix the issue?

by (301k points)

At first I thought it was an antivirus, but when I close the application I wrote with ftp.dll, the file I downloaded is fixed.

I double checked and Ftp.dll disposes the local stream as soon as the download is finished.

I can read or delete the downloaded file with no problems - it is not in use after the download.

...