Subject: Cannot close the stream from ComponentPro.Net.Ftp.GetDownloadStream Date: 2018-03-30 11:54:42 From: info@rw-sd.de Source: cannot-close-stream-componentpro-net-ftp-getdownloadstream ---------------------------------------------------------------------- Hello, I want to read just the first few bytes from an ftp to check, if it is the right file, then close that stream and reopen it at position 0 (since setting Stream.Position = 0 will not work) But unfortunately, I cannot close the stream I got from GetDownloadStream. And if I do not close it, anythinge else (like even trying to Diconnect) runs into a FtpException "Cannot execute the operation because the Ftp object is locked by another operation which is still in progress." ComponentPro.Net.Ftp ftp; ftp.Connect... ftp.Authenticate... ... Stream downloadStream = ftp.GetDownloadStream(Filename); byte[] buffer = new byte[10]; int count = downloadStream.Read(buffer, 0, 10); //till here it's working, the 10 bytes are read correctly downloadStream.Close(); // takes a very long time and then throws an InvalidOperationException "No response from the server is expected." downloadStream = ftp.GetDownloadStream(Filename); BTW: This code is running in a background thread What I am doing wrong? ---------------------------------------------------------------------- Note: This question has been asked on the Q&A forum of Thang Dang's fraudulent ComponentPro brand If you purchased anything from ComponentPro, you have been scammed. Contact the payment processor who sold you the license and ask for your money back. Back to ComponentPro Q&A Forum Index