سؤال

i have saved a file named 'logo.jpg' in the isolatedstorage using this code...

private void step2_Click(object sender, RoutedEventArgs e)
        {
            // Create a filename for JPEG file in isolated storage.
            String tempJPEG = "logo.jpg";

            // Create virtual store and file stream. Check for duplicate tempJPEG files.
            using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
            {
                if (myIsolatedStorage.FileExists(tempJPEG))
                {
                    myIsolatedStorage.DeleteFile(tempJPEG);
                }

                IsolatedStorageFileStream fileStream = myIsolatedStorage.CreateFile(tempJPEG);

                try
                {
                    WriteableBitmap wb = new WriteableBitmap(img);

                    // Encode WriteableBitmap object to a JPEG stream.
                    Extensions.SaveJpeg(wb, fileStream, wb.PixelWidth, wb.PixelHeight, 0, 85);
                }
                catch { }
                //wb.SaveJpeg(fileStream, wb.PixelWidth, wb.PixelHeight, 0, 85);
                fileStream.Close();
            }
            NavigationService.Navigate(new Uri("/Stage2.xaml?num="+Contact_number.Text+"&name="+contact_name.Text, UriKind.Relative));
        }

and creating tile using this function..

private StandardTileData GetSecondaryTileData()
    {
        string filePath = System.IO.Path.Combine(@"/Shared/ShellContent", "logo.jpg");

        StandardTileData tileData = new StandardTileData
        {
            Title = name,
            BackgroundImage = new Uri(@"isostore:" + filePath, UriKind.Absolute),
            Count = 0,
            BackTitle = "app",
            BackBackgroundImage = new Uri("", UriKind.Absolute),
            BackContent = "content"
        };

but it is throwing an exception "An exception of type 'System.UriFormatException' occurred in System.ni.dll but was not handled in user code

Additional information: Invalid URI: The URI is empty."

هل كانت مفيدة؟

المحلول

the problem was that image was not in the shared/shellcontent/ and also

BackBackgroundImage = new Uri("", UriKind.Absolute),

this is incorrect. it should be relative if the tile has to be kept blank... took so many hours. huff

نصائح أخرى

use this

MediaLibraryExtension.GetPath(p);

here p is the object of Class Picture(that is the picture for which it will return the path)

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top