var filePath = "/Volumes/StorageHD/Audio/iTunes Music/Air/Talkie Walkie/01 Venus.mp3"; var p = new Process(); p.StartInfo.FileName = "/Applications/VLC.app/Contents/MacOS/VLC"; p.StartInfo.Arguments= filePath; p.Start(); Console.ReadKey();
This code launches VLC, but each space in the file path is parsed as a new file name, so VLC attempts (and fails) to play iTunes, Talkie, Walkie, 01 and Venus.mp3.
My first attempt to fix this was to escape the file path as a Unix file path i.e.
"/Volumes/StorageHD/Audio/iTunes\ Music/Air/Talkie\ Walkie/01\ Venus.mp3"
which is what I'd use if I were trying to do something similar from the shell:
$ vlc /Volumes/StorageHD/Audio/iTunes\ Music/Air/Talkie\ Walkie/01\ Venus.mp3
This was not the correct option ;) - my little console application threw a lot of stack-tracey goodness, but the main point was "Unrecognized escape sequence".
Instead I needed to escape the path as I would on windows, with the path with spaces in wrapped in double quotes:
var filePath = "\"/Volumes/StorageHD/Audio/iTunes Music/Air/Talkie Walkie/01 Venus.mp3\"";
Notice the escape character ("\") before the wrapping quote.
The final full code is available as a gist https://gist.github.com/StephenFriend/593aa94366cd4733be46
ReplyDeleteThank you for giving the information and it is useful for me. training with placement company in Hyderabad
ReplyDeleteThank you so much for posting this. I really appreciate your work. Keep it up. Great work!
best courier service in India