I'm getting the above exception and error on the following code, which is meant to play a selected mp3 file from Isolated Storage:
using (var isf = IsolatedStorageFile.GetUserStoreForApplication())
{
using (var isfs = isf.OpenFile(selected.Path, FileMode.Open))
{
this.media.SetSource(isfs);
isfs.Close();
}
isf.Dispose();
}
The error is so vague that I'm not really sure what could be wrong... Any ideas or at least common sources of this error that I could potentially check for?
EDIT: the exception is being thrown at: using(var isfs = isf.OpenFile(...))
EDIT 2: The stack trace...
at System.IO.IsolatedStorage.IsolatedStorageFileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, IsolatedStorageFile isf)
at System.IO.IsolatedStorage.IsolatedStorageFileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, IsolatedStorageFile isf)
at System.IO.IsolatedStorage.IsolatedStorageFileStream..ctor(String path, FileMode mode, IsolatedStorageFile isf)
at Ringify.Phone.PivotContent.RingtoneCollectionPage.MediaIconSelected(Object sender, GestureEventArgs e)
at MS.Internal.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args)
at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)
I've realized too that the error does NOT occur if I play one song then stop it (there is a play and pause button in the UI), then play another song. It occurs when I play one song, stop it, and attempt to play the same song again.
isf.FileExists(selected.Path)
before opening the file – Kevin Gosseisf.FileExists(selected.Path)
since I thought maybe that was the case, but it does and putting in a an actual if-statement doesn't solve the problem. – Amy Liselected.Path
? – Kevin Gosse