문제

I programmed (C# .Net 3.5) a process to start when windows (XP) starts. This process uses other files in the same folder as itself. Moreover, it starts another process, again located in the same folder.

However, it seems like the process cannot find the files in the same folder (they are there). Instead, it looks in "C:\Documents and Setting\User" folder. Whenever, all the files are in this folder it starts properly but NOT when they are in a different folder.

The process is made to start with Windows start-up by registering it in HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top