I am trying to code something that will essentially concat a bunch of files together into 1 output file.
my code is as follows
string[] destination = new string[this.lbFiles.Items.Count];
this.lbFiles.Items.CopyTo(destination, 0);
string result1 = ConvertStringArrayToString(destination);
result1 = result1.Remove(result1.Length - 3);
string outputfile = this.saveFileDialog1.FileName;
string copyarg = "copy /b " + result1 + quote + outputfile + quote;
System.Diagnostics.Process.Start("CMD.exe", copyarg);
So basically result1 = all the files i’m trying to concatenate. with full paths and quotes. and outputfile = the output file name i want to use with full path.
My problem is, when I execute the code, it copys the files, but it doesnt use the output file name I have specified, and it outputs the file to the directory where the program exe is located, not the path I have specified.
Any help?
You appear to be either missing a quote in there, or a space. You’re removing the last three characters of result1, which I assume are “
+“, and then immediately adding a quote. This would producecopy /b "d:\test1.ac3" + "d:\test2.ac3""d:\output.ac3".I would assume this would error, but if it doesn’t, it could certainly produce your odd behavior. Especially if your file names actually have spaces in them.