开发者

Saving multiple images to isolated storage

I was trying to save multiple images into isolated storage b开发者_如何学编程y using creating a imageFolder in isolated storage and storing all my images inside.But it have an error so please anyone could help me solve the error or got other method way help me thanks.IF possible I would appreciate if you guys can show me your code that works. Actually my code would like to be under a button event handler.Thanks And the error is :Operation not permitted on IsolatedStorageFileStream.

My Code :

         private void SaveToLocalStorage(string imageFolder, string imageFileName)
    {
        imageFileName = name.Text;
        MessageBox.Show(imageFileName);

        var isf = IsolatedStorageFile.GetUserStoreForApplication();
        if (isf.DirectoryExists(imageFolder))
        {
            isf.CreateDirectory(imageFolder);
        }

        string filePath = Path.Combine(imageFolder, imageFileName);
        MessageBox.Show(filePath);
        using (var stream = isf.CreateFile(filePath))
        {
            var bmp= new WriteableBitmap(inkCanvas, inkCanvas.RenderTransform);
            bmp.SaveJpeg(stream, bmp.PixelWidth, bmp.PixelHeight, 0, 100);
      }
}


First off, you probably want to be creating the directory if it DOESN'T exist, not if it does:

    if (!isf.DirectoryExists(imageFolder))
    {
        isf.CreateDirectory(imageFolder);
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜