且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在 Windows 启动时启动进程(找不到支持文件)

更新时间:2022-03-03 06:47:38

您可以尝试在启动流程时设置工作目录:

You may try setting the working directory when you start your process:

Directory.SetCurrentDirectory(
    Path.GetDirectoryName(
        Assembly.GetExecutingAssembly().Location
    )
);

如果您稍后尝试通过指定相对路径来访问与进程可执行文件相同的目录中的文件,它应该能够找到它.

If you later try accessing a file in the same directory as the process executable by specifying a relative path it should be able to find it.