简体   繁体   中英

wp7 - stream creating issue

I am trying to make my app save pictures from remote host via SSH and SCP and I need to create an empty Stream variable to full it with ScpClient.Download(string filename, Stream destination ) method to use it later. Is there any way to do that? I tried:

        Stream downloadStream = new MemoryStream();

        scpClient.Connect();
        scpClient.Download("remoteFilename", downloadStream);

        MediaLibrary localLibrary = new MediaLibrary();
        localLibrary.SavePicture("localFilename", downloadStream);

        MessageBox.Show("Success!", "Result", MessageBoxButton.OK);

I am getting unknown exception or the app just quits. Maybe there is a way to pass the image throw the IsolatedStorage ? I am using Renci.SshNet library.

You should put your code in a try ... catch block

        try
        {
            // your stuff
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }

Then add your exception details to your question, you'd get more help from people in here.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM