Home Forums .NET libraries Xceed SFTP/FTP for .NET i cant retrive files ater images

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #21453 |

    when i use this code to get image then do any thing after that using ftp it is throw esception

     

     Stream stream = new MemoryStream();

    //get image

     stream = http://ftp.GetDownloadStream(files[i].Name);

     

    then try to use this 

     string d= http://ftp.GetCurrentFolder();

    it was throw exception 

    Cannot perform the requested operation because the FTP client is already processing a command.
     

    Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by omar (had 941 views)

    Fawzi [Xceed]
    Member
    Post count: 722

    Hi Omar,

     

    Most likely, you didn’t close the stream object before calling GetCurrentFolder().

    GetDownloadStream() issues a “receive file” command to the server and lets you control the download stream. The FTP client remains in a “ReceivingFile” state until the stream is closed.

    Source:
    http://doc.xceedsoft.com/products/XceedFileSystem/#topic1973.html

    You could change your code to the following:

    Stream destinationStream = new MemoryStream();

    // Get a download stream for the current file
    using( Stream stream = http://ftp.GetDownloadStream( files[i].Name ) )
    {
      byte[] buffer = new byte[ 32 * 1024 ];
      int read;

      // While there is data to download
      while( ( read = stream.Read( buffer, 0, buffer.Length ) ) > 0 )
      {
        // Write the downloaded data to our destination stream
        destinationStream.Write( buffer, 0, read );
      }
    }

    // Get the current folder

    string d = http://ftp.GetCurrentFolder(); 

     

     

    Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by Fawzi [Xceed] (had 296 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.