2

I'm trying to compare two folders using a third party comparison tool called UltraCompare. The following line calls the program and opens two files... but this doesn't do anything except open them, plus it doesn't work properly for folders.

Process.Start("C:\\Program Files\\IDM Computer Solutions\\UltraCompare\\uc.exe", 
textBoxContents1 + " " + textBoxContents2);

I'd like to use the following command line call which opens two folders, runs a comparison on them, and stores the results in output.txt: uc -d -dmf "c:\dir1" "c:\dir2" -o "c:\output.txt"

Also, I'd need to use variables for the folders instead of hardcoding the paths.

How can I work that into my C# code?

UPDATE 1:

I've modified my code according to your suggestions:

var p = new System.Diagnostics.Process();
p.StartInfo.FileName = "C:\\Program Files\\IDM Computer Solutions\\UltraCompare\\uc.exe";
p.StartInfo.Arguments = String.Format("-d -dmf \"{0}\" \"{1}\" -o c:\\output2.txt",
textBoxContents1, textBoxContents2);
p.Start();

I'm wondering why the third line containing the arguments still doesn't work...

UPDATE 2:

My mistake. It is working now!! Just doesn't display the folders in UltraCompare but it is still writing and saving the output. Thanks guys!

2
  • Are you asking how to concatenate strings? Commented Jan 29, 2013 at 16:33
  • For your folders problem, quote all your string: Process.Start("""C:\\Program Files\\file.exe""") Commented Jan 29, 2013 at 16:36

3 Answers 3

6

You can use

yourProcess.StartInfo.Arguments = " .....";

Sample

var p = new System.Diagnostics.Process();
p.StartInfo.FileName = "C:\\Program Files\\IDM Computer Solutions\\UltraCompare\\uc.exe";
p.StartInfo.Arguments = String.Format("-d -dmf {0} {1} -o c:\output.txt",textBoxContents1,   textBoxContents2);
p.Start();
Sign up to request clarification or add additional context in comments.

7 Comments

this works... except it's screwing up the locations of both folders! I modified the third line a bit to use the variables for the folder locations: p.StartInfo.Arguments = "-d -dmf" + textBoxContents1 + " " + textBoxContents2 + "-o c:\\output.txt"; Do you think this could be the problem?
i'am happy to help you user1985189, you can format your string
the file locations, as specified by textBoxContents1 and 2, are C:\Toms Work\WebSite1 and C:\Toms Work\WebSite2 but it looks like it's trying to open C:\Program Files\Common Files\Microsoft Shared\DevServer\10.0\Work\WebSite2-o and C:\Toms instead...
I tried your formatted code but it gives me a message from UltraCompare saying "unsupported operation" and won't open at all. :(
I belive you need to add double quotes within the path name. String.Format("-d -dmf \"{0}\" \"{1}\" -o c:\output.txt",textBoxContents1
|
5
Process.Start(new ProcessStartInfo
{
   FileName = @"C:\Program Files\IDM Computer Solutions\UltraCompare\uc.exe",
   Arguments = String.Format("\"{0}\" \"{1}\"", textBoxContents1, textBoxContents2)
});

Comments

1

Make sure you use quotation marks for arguments, too! If any of textBoxContents1 or textBoxContents2 contains spaces, you are busted!

1 Comment

do you mean that this won't work if the file path contains spaces? such as the space between "Toms" and "Work" in C:\Toms Work\WebSite1?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.