Click here to Skip to main content
15,885,694 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I've an app that is trying to call a .txt file from the project root. The file is defined as in the config:
XML
<add key="BCReportSpec-Full" value=".\BC_DiffReportFull.txt"/>


but when the process in this method tries to run, I am getting the error can not find file '.\BC_DiffReportFull.txt'

C#
// Call BeyondCompare, pass it the parameters and generate the report
protected void compare(string file1, string file2, string outputFile, string reportParamFile)
{
    if (File.Exists(file1) && File.Exists(file2))
    {
        System.Diagnostics.Process proc = new System.Diagnostics.Process();
        proc.EnableRaisingEvents = false;
        proc.StartInfo.FileName = BCFileSpec;
        proc.StartInfo.Arguments = "@\"" + reportParamFile + "\" \"" + file1 + "\" \"" + file2 + "\" \"" + outputFile + "\" /silent";
        proc.StartInfo.CreateNoWindow = true;
        proc.Start();
        proc.WaitForExit();
        proc.Close();
    }
    else
    {
        ...
    }
    return;
}
Posted

1 solution

The project root is not the same as where the executable runs. The file needs to be placed in the bin\Debug or bin\Release folder.
 
Share this answer
 
Comments
H.Brydon 10-Jan-14 20:55pm    
...or in the same directory as the executable if the app is deployed or otherwise run outside the IDE.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900