简体   繁体   中英

C# base directory access denied

I am trying to read a text file for my program. When debugging, using

string fullPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"text files", path);

works fine, but when I run the .exe file I get

Access to the path: '' is denied

How do I go about fixing this?

It might be possible that exe is open in task manager. See the process is open or not if open write the code below to stop the process.

Process[] processes = Process.GetProcessesByName("abc.exe");

if (processes.Length > 0)
    processes[0].CloseMainWindow();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM