How can I open a file in wp7?

Go To StackoverFlow.com

0

I have some files in IsolatedStorage in my application. The file types are different, say doc,xls,ppt,pdf,mp3,mov,jpg,png etc.. I need to open these files. How can I do this.

2012-04-04 06:13
by Nelson T Joseph


2

Try to open it with name and its extensions

byte[] data;

        using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication())
        {

            using (IsolatedStorageFileStream isfs = isf.OpenFile(image.jpg, FileMode.Open, FileAccess.Read))
            {
                data = new byte[isfs.Length];
                isfs.Read(data, 0, data.Length);
                isfs.Close();
            }

        }


        MemoryStream ms = new MemoryStream(data);

        BitmapImage bi = new BitmapImage(); 
        bi.SetSource(ms); 
        Image img = new image(); 
        img.source = bi

if it is an image try to set the source of a bitmap image as memory stream ms.

2012-04-04 11:49
by SENTHIL KUMAR
When I am trying to set the memorystream as Source of image, it throws an exception. The error message is "Unspecified error - Nelson T Joseph 2012-04-04 12:31
try to have like this BitmapImage bi = new BitmapImage(); bi.SetSource(ms); Image img = new image(); img.source = bi - SENTHIL KUMAR 2012-04-04 13:07
Even if change var to BitmapImage, the same error occure - Nelson T Joseph 2012-04-05 03:48
Ads