I am trying to pass a full file path to FFMPEG.
C:\TestFolder\Input\Friends - Season 6 - Gag Reel.avi
and it's obviously not liking the fact the path has spaces in it, erroring like so:
C:\TestFolder\Input\Friends: no such file or directory
So what's the easiest way to use filenames with spaces in them? Should I just replace all whitespaces with ~ characters or is there a better way? I have tried escaping the string with various characters:
@"C:\TestFolder\Input\Friends - Season 6 - Gag Reel.avi";
But this doesn't work. Is there a trick to preserving spaces?
C programming language is a machine-independent programming language that is mainly used to create many types of applications and operating systems such as Windows, and other complicated programs such as the Oracle database, Git, Python interpreter, and games and is considered a programming foundation in the process of ...
In the real sense it has no meaning or full form. It was developed by Dennis Ritchie and Ken Thompson at AT&T bell Lab. First, they used to call it as B language then later they made some improvement into it and renamed it as C and its superscript as C++ which was invented by Dr.
C is a general-purpose language that most programmers learn before moving on to more complex languages. From Unix and Windows to Tic Tac Toe and Photoshop, several of the most commonly used applications today have been built on C. It is easy to learn because: A simple syntax with only 32 keywords.
C is an imperative procedural language supporting structured programming, lexical variable scope, and recursion, with a static type system. It was designed to be compiled to provide low-level access to memory and language constructs that map efficiently to machine instructions, all with minimal runtime support.
System.IO.Path provides several methods for manipulating filenames...
In general, file paths passed as arguments on the command line require the path to be surrounded with quotation marks.
If you're talking about accepting file paths as an argument to your program, it's easiest to require users to quote paths. That way, the args
argument to your main method will contain the whole path as a single string.
If you're calling other programs and passing arguments, file paths with spaces must be quoted.
Process p = new Process();
p.StartInfo.FileName = "notepad.exe";
p.StartInfo.Arguments = string.Format("\"{0}\"", filePath);
p.Start();
The only time you'll typically have to do any special handing with filenames that have spaces is when you're passing them to external tools or formats. If you're constructing an argument list for an external executable, for instance, all you have to do is quote the path:
string path = @"C:\TestFolder\Input\Friends - Season 6 - Gag Reel.avi";
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = "program.exe";
psi.Arguments = "\"" + path + "\""; // escape the quotes
...which will result in this commandline:
program.exe "C:\TestFolder\Input\Friends - Season 6 - Gag Reel.avi"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With