用C#编写删除文件的exe运行成功但是没能实现文件的删除
时间:2011-12-06
来源:互联网
下面是我编写的程序,本人是新手,将其存为exe 后在系统运行,没有错误提示,但是b.txt没被删除
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
namespace ConsoleApplication20
{
class Program
{
static void Main(string[] args)
{Process p=new Process() ;
p.StartInfo .FileName ="cmd.exe" ;
p.StartInfo .UseShellExecute =false ;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.CreateNoWindow = false;
p.Start();
p.StandardInput.WriteLine("del c:\b.txt");
p.StandardInput.WriteLine("exit");
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
namespace ConsoleApplication20
{
class Program
{
static void Main(string[] args)
{Process p=new Process() ;
p.StartInfo .FileName ="cmd.exe" ;
p.StartInfo .UseShellExecute =false ;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.CreateNoWindow = false;
p.Start();
p.StandardInput.WriteLine("del c:\b.txt");
p.StandardInput.WriteLine("exit");
}
}
}
作者: qipaodianxssl 发布时间: 2011-12-06
这是什么跟什么呀,没有执行怎么删除
作者: DENQH 发布时间: 2011-12-06
p.start不是执行么。。。。
作者: qipaodianxssl 发布时间: 2011-12-06
File.Delete(。。。)不是更好吗?
作者: Icedmilk 发布时间: 2011-12-06
只是实验下调用DOS的功能。。。
作者: qipaodianxssl 发布时间: 2011-12-06
如果不是这样的化,那么怎么写才能实现调用DOS并且成功执行DOS下命令
作者: qipaodianxssl 发布时间: 2011-12-06
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28