c# - 菜鸟 file.copy 问题在复制 .exe 文件时出现问题 C#

标签 c# file copy executable

我正在尝试将一个 .exe 文件从临时目录复制到桌面,但是当我这样做时,它只会创建一个新的 .exe,其中没有数据,大小为 0 KB。我用一个 .txt 文件测试了这个语法,它完全复制了它,它只是出于某种原因拒绝复制 .exe 文件。我尝试使用 string path 执行它以确保它正在抓取正确的位置并且有效,在临时目录中执行 helloworld.exe 程序。我也没有收到任何编译器错误,我在 Windows 7 x86 上。谢谢!

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 是否在复制过程中使用?

或者,AV 软件是否有可能阻止您的应用制作 .exe 副本?

关于c# - 菜鸟 file.copy 问题在复制 .exe 文件时出现问题 C#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5972031/

相关文章:

c++ - C++ “Using Uninitialized Memory.. (variable name) ”

php 上传脚本不起作用

linux - VI中如何知道光标在哪一行?

c++ - 可以在基类中定义复制构造函数并仍然处理派生类情况吗?

c# 如何检查一个数是否为无穷大

c# - 当使用 C# 删除和替换工作表时,如何保留公式对工作表的引用?

c# - 如何从泛型类或方法的成员获取 T 的类型

c# - asp.net core 路径遍历漏洞

c - 当写入 txt 的输入数据大于 16kb 时应用程序崩溃(C 编程)

python - 如何使用 python 执行非递归复制