WebEnh

.net7 mvc jquery bootstrap json 学习中 第一次学PHP,正在研究中。自学进行时... ... 我的博客 https://enhweb.github.io/ 不错的皮肤:darkgreentrip,iMetro_HD
随笔 - 1079, 文章 - 1, 评论 - 75, 阅读 - 174万
  首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
< 2025年2月 >
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 1
2 3 4 5 6 7 8

winfrom 程序自己删除自己

Posted on   WebEnh  阅读(10)  评论(0编辑  收藏  举报
复制代码
   [DllImport("kernel32.dll")]
        public static extern uint WinExec(string lpCmdLine, uint uCmdShow);

  private void button1_Click(object sender, EventArgs e)
        {
  string vBatFile = Path.GetDirectoryName(Application.ExecutablePath) + "\\Zswang.bat";//这个是bat文件 不可更改成别的名称。
            using (StreamWriter vStreamWriter = new StreamWriter(vBatFile, false, Encoding.Default))
            {
                vStreamWriter.Write(string.Format(
                ":del\r\n" +
                " del \"{0}\"\r\n" +
                "if exist \"{0}\" goto del\r\n" +
                "del %0\r\n", Application.ExecutablePath));
            }

            WinExec(vBatFile, 0);
}
复制代码

 

相关博文:
阅读排行:
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· 没有源码,如何修改代码逻辑?
· PowerShell开发游戏 · 打蜜蜂
· 在鹅厂做java开发是什么体验
· WPF到Web的无缝过渡:英雄联盟客户端的OpenSilver迁移实战
历史上的今天:
2019-05-27 cshtml 中的 AppState = Context.Application 和 控制器中的 Application 也相等
点击右上角即可分享
微信分享提示

喜欢请打赏

扫描二维码打赏

了解更多