从Root文件夹调用文件 [英] call file from Root folder

查看:73
本文介绍了从Root文件夹调用文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个试图从项目根目录调用.txt文件的应用程序。该文件在配置中定义:

I've an app that is trying to call a .txt file from the project root. The file is defined as in the config:

<add key="BCReportSpec-Full" value=".\BC_DiffReportFull.txt"/>





但是当此方法中的进程尝试运行时,我收到错误无法找到文件'.\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'

// 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;
}

推荐答案

项目根目录与可执行文件的运行位置不同。该文件需要放在bin \Debug或bin \ Release文件夹中。
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.


这篇关于从Root文件夹调用文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆