×

Discussion Board

Results 1 to 11 of 11
  1. #1
    Registered User
    Join Date
    Jun 2014
    Posts
    11

    Any Isolated storage gurus? Getting Operation not permitted on IsolatedStorageFileStr

    Operation not permitted on IsolatedStorageFileStream error during the following scnerio (code below):

    When a user first opens my app, one press of a button will download that buttons sound. The second press will play the sound. However, the error occurs any time you try to play the same sound twice in a row. You can go to another button and then back to the initial button, but never can play twice in a row with out crashing. The error occurs at this line:

    audioStream = IsolatedStorageFile.GetUserStoreForApplication().OpenFile(data.SavePath, FileMode.Open);



    Code:
    private void LongListSelector_SelectionChanged(object sender, SelectionChangedEventArgs e)
            {
                LongListSelector selector = sender as LongListSelector;
    
                // verifying our sender is actually a LongListSelector
                if (selector == null)
                    return;
    
                SoundData data = selector.SelectedItem as SoundData;
    
                // verifying our sender is actually SoundData
                if (data == null)
                    return;
    
    
                if (data.IsDownloaded)
                {
                    if (audioStream != null)
                    {
                        audioStream.Close();
                        audioStream.Dispose();
                    }
    
                    audioStream = IsolatedStorageFile.GetUserStoreForApplication().OpenFile(data.SavePath, FileMode.Open);
    
                    // Apparently MediaElement doesn't like isostore:/
                    AudioPlayer.SetSource(audioStream);
                    AudioPlayer.Play();
                }
                else
                {
                    // TODO: the application should check if there is an internet connection available and warn the user if 
                    // it's disconnected. Otherwise it won't pass certification.
                    WebClient client = new WebClient();
                    client.OpenReadCompleted += (senderClient, args) =>
                        {
                            using (IsolatedStorageFileStream fileStream = IsolatedStorageFile.GetUserStoreForApplication().CreateFile(data.SavePath))
                            {
                                args.Result.Seek(0, SeekOrigin.Begin);
                                args.Result.CopyTo(fileStream);
                            }
                        };
                    client.OpenReadAsync(new Uri(data.FilePath));
                }
                selector.SelectedItem = null;
    
            }

    Another minor annoyance is how it doesn't play the sound automatically after downloading. I tried playing with the code but can not get that to work. I know there's a way but I haven't figured that out. But the crashing on the above error is obviously the biggest problem

  2. #2
    Nokia Developer Champion
    Join Date
    Jun 2008
    Location
    Gurgaon,India
    Posts
    4,102

    Re: Any Isolated storage gurus? Getting Operation not permitted on IsolatedStorageFil

    Probably #2 here can help you out : http://stackoverflow.com/questions/8...lestream-error

  3. #3
    Registered User
    Join Date
    Jun 2014
    Posts
    11

    Re: Any Isolated storage gurus? Getting Operation not permitted on IsolatedStorageFil

    Thanks. Seems to have worked when I modified it to this:

    audioStream = IsolatedStorageFile.GetUserStoreForApplication().OpenFile(data.SavePath, FileMode.Open, FileAccess.Read, FileShare.Read);

    One other thing. What can I add to get the file to play automatically after downloading? Any ideas?

  4. #4
    Nokia Developer Champion
    Join Date
    Jun 2008
    Location
    Gurgaon,India
    Posts
    4,102

    Re: Any Isolated storage gurus? Getting Operation not permitted on IsolatedStorageFil

    Well you can try putting the audio play code just after saving it , shifting it from 2nd button press.

  5. #5
    Registered User
    Join Date
    Jun 2014
    Posts
    11

    Re: Any Isolated storage gurus? Getting Operation not permitted on IsolatedStorageFil

    Yeah, tried that and it doesn't like it. When I do that, it errors on the first press.

  6. #6
    Nokia Developer Champion
    Join Date
    Jun 2008
    Location
    Gurgaon,India
    Posts
    4,102

    Re: Any Isolated storage gurus? Getting Operation not permitted on IsolatedStorageFil

    And the error is?, probably some debugging may help.

  7. #7
    Registered User
    Join Date
    Jun 2014
    Posts
    11

    Re: Any Isolated storage gurus? Getting Operation not permitted on IsolatedStorageFil

    A first chance exception of type 'System.ArgumentNullException' occurred in System.Windows.ni.dll
    An exception of type 'System.ArgumentNullException' occurred in System.Windows.ni.dll but was not handled in user code
    Additional information: Value cannot be null.

    This after putting
    Code:
    AudioPlayer.SetSource(audioStream);
                    AudioPlayer.Play();
    after

    Code:
    WebClient client = new WebClient();
                    client.OpenReadCompleted += (senderClient, args) =>
                        {
                            using (IsolatedStorageFileStream fileStream = IsolatedStorageFile.GetUserStoreForApplication().CreateFile(data.SavePath))
                            {
                                args.Result.Seek(0, SeekOrigin.Begin);
                                args.Result.CopyTo(fileStream);
                            }
                        };
                    client.OpenReadAsync(new Uri(data.FilePath));
    Seems it tries to play the file before it even downloads so it sees it as null since its not downloaded yet.

  8. #8
    Nokia Developer Champion
    Join Date
    Jun 2008
    Location
    Gurgaon,India
    Posts
    4,102

    Re: Any Isolated storage gurus? Getting Operation not permitted on IsolatedStorageFil

    That's inevitable actually, OpenReadAsync is an 'Async' method, proceeds to next line of code without blocking the thread.Try placing the audio playing code inside OpenReadCompleted event.

  9. #9
    Registered User
    Join Date
    Jun 2014
    Posts
    11

    Re: Any Isolated storage gurus? Getting Operation not permitted on IsolatedStorageFil

    Yeah, Ive been trying that actually. There must be a very specific way to add that to that event with out messing other things up. Its not liking any way I add the Audioplay in there.

  10. #10
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    526

    Re: Any Isolated storage gurus? Getting Operation not permitted on IsolatedStorageFil

    The event is triggered on a background thread as the whole Async is moving it there. So it's likely that when you call the player component (which is on the UI thread) will have issues with that. Or are you always getting the access exception you posted?

  11. #11
    Registered User
    Join Date
    Jun 2014
    Posts
    11

    Re: Any Isolated storage gurus? Getting Operation not permitted on IsolatedStorageFil

    Quote Originally Posted by SB Dev View Post
    The event is triggered on a background thread as the whole Async is moving it there. So it's likely that when you call the player component (which is on the UI thread) will have issues with that. Or are you always getting the access exception you posted?
    Forgot to update the thread. Below is what worked. I thought I tried this already but I must've typed something wrong before.

    Code:
         using (IsolatedStorageFileStream fileStream =  IsolatedStorageFile.GetUserStoreForApplication).CreateFile(data.SavePath))                     
    {                         
    args.Result.Seek(0, SeekOrigin.Begin);
    args.Result.CopyTo(fileStream);
    AudioPlayer.SetSource(fileStream); 
    AudioPlayer.Play();

Similar Threads

  1. Image in Isolated Storage as background
    By shinobi86 in forum Windows Phone General
    Replies: 1
    Last Post: 2013-12-09, 08:33
  2. Replies: 29
    Last Post: 2011-07-24, 11:23
  3. Replies: 1
    Last Post: 2010-11-15, 05:16
  4. creating a secure and isolated IPC server ?
    By navjotsingh1979 in forum Symbian
    Replies: 11
    Last Post: 2007-05-21, 11:05
  5. Problem Isolated. Bug in 6200?
    By johnyin in forum Mobile Java General
    Replies: 2
    Last Post: 2004-03-03, 13:59

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×