locked
Convert a path with spaces to a URI

    Question

  • Can somebody help me with this.  I've spent the last 3 hours on it.

    I want to convert a regular file path (with spaces) into a URI to pass to MediaElement.Source, but no matter what I do, this fails.

    ' Open the picker for the user to pick a file
            Dim storagefile = Await openPicker.PickSingleFileAsync()

            Dim MYuri As String = New Uri(storagefile.Path).AbsoluteUri

            MyMediaElement.Source = (New Uri(MYuri))

    Monday, June 2, 2014 1:42 AM

Answers

  • You can't use a path here. Your app doesn't have permissions to read from it. The app has to let the StorageFile read the file and return the stream for the app to use.

    Open the stream with storagefile.OpenAsync and pass that string to MyMediaElement.SetSource

    Monday, June 2, 2014 1:48 AM
    Owner