如何将执行的程序复制到另一个目录 [英] How copy executed program to another directory

查看:96
本文介绍了如何将执行的程序复制到另一个目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我想知道如何将执行的程序复制到另一个目录,您能帮我吗?
示例:我运行我的程序(test.exe),并且在Form1_Load上,必须将文件test.exe复制到另一个目录! 希望你能理解我...

问候,
KZ

hi people,
I want to know how can I copy the executed program to another directory, can you help me?
Example: I run my program (test.exe), and on Form1_Load the file test.exe must be copy to another directory!
I hope you understand me...

regards,
KZ

推荐答案

听起来不是个好主意,但是...
Does not sound like a good idea, but...
File.Copy(Application.ExecutablePath, @"D:\Temp\myFile.EXE");


这不是一个好主意,因为您根本不会阻止任何操作.复制.EXE文件根本对您没有任何帮助.

如果用户具有足够的权限来更改或删除应用程序程序文件"文件夹中的内容,则您已向用户授予了对应用程序文件夹的过多权限.在Visa和7下,普通用户无法在Program Files下编写或删除任何内容,除非安装程序授予他们这些权限,否则在编写应用程序和安装程序时,您所做的事情非常愚蠢.

接下来,如果MSI安装程序的编写正确,如果用户确实删除了.EXE,则下次启动该应用程序时,这些文件将被自动修复安装替换.
It''s not a good idea because you''re not preventing anything at all. Copying the .EXE file will do nothing for you at all.

If the user has sufficient permissions to alter or delete what''s in your applications Program Files folder, you''ve given the user too many permissions to the application folder. Under Visa and 7, normal users do not have the ability to write or delete anything under Program Files, unless your installer has given them those permissions, in which case YOU have done something very stupid when you wrote your app and installer.

Next, if the MSI installer is written correctly, if the user does delete the .EXE, the files will be replaced by an automatic repair install the next time the application is launched.


这篇关于如何将执行的程序复制到另一个目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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