Noob file.copy问题在复制.exe文件C#时遇到问题 [英] Noob file.copy question having issues copying .exe files C#

查看:72
本文介绍了Noob file.copy问题在复制.exe文件C#时遇到问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将.exe文件从temp目录复制到桌面,但是这样做时,它只是创建一个新的.exe,其中没有数据,大小为0 KB。我使用.txt文件测试了此语法,并完全复制了该语法,由于某种原因,它只是拒绝复制.exe文件。我尝试使用字符串路径执行它,以确保它获取了正确的位置并且有效,然后在temp目录中执行helloworld.exe程序。我也没有得到任何编译器错误,我在Windows 7 x86上。

I am trying to copy a .exe file from the temp directory to the desktop, however when I do so it just creates a new .exe which has no data in it and is 0 KB in size. I tested this syntax with a .txt file and it copied it completely, it just refuses to copy .exe files for some reason. I tried executing it using the the string path to make sure it was grabbing the correct location and that worked, executing the helloworld.exe program in the temp directory. Also I do not get any compiler errors, I am on windows 7 x86. Thanks!

string path = Path.GetTempPath() + "helloworld.exe"; // grabing the temp directory
string path2 = "C:\\users\\grant\\desktop\\helloworld.exe"; //this is where i want
                                                          //it to copy to
File.Copy(path, path2, true); //copying the 2 paths
Process.Start(path); //running the .exe in the temp directory to test if it works


推荐答案

在复制过程中是否使用了 .exe

Is the .exe in use during the copy?

或者,AV软件停止的任何可能性您的应用制作了 .exe 份?

Alternatively, any chance AV software is stopping your app making .exe copies?

这篇关于Noob file.copy问题在复制.exe文件C#时遇到问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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