我使用C#将一个文件从一个目录复制到另一个目录。示例 test.exe用于将当前文件夹中的文件复制到正在运行的文件夹 访问路径测试.exe被拒绝。错误将来......如何避免此错误
I have one copy a file from one directory to another directory using C#. Example The test.exe is used to copy file in one folder to running folder at that time "Access to the path "test.exe" is denied." error will come... how to avoid this error
推荐答案您登录PC的用户(运行.exe文件的用户)需要读取和执行权限到exe文件所在的那个目录。 The user you logged in you PC(under which the .exe file will run) needs read & execute permission to that directory where the exe file exists.
可能是text.exe在任务管理器中打开看到进程是否打开 如果打开就写了下面的代码停止进程 may be text.exe is open in task manager see the process is open or not if open you write the code below to stop the process Process[] processes = Process.GetProcessesByName("test.exe"); if (processes.Length > 0) processes[0].CloseMainWindow();
然后编写代码以复制文件
and then write your code to copy the file