C# 创建文件并往文件里写内容
2008-01-30 10:34
190 查看
protected void btnCreate_Click(object sender, EventArgs e)
...{
string path = HttpContext.Current.Request.PhysicalPath;
string file = path.Substring(0,path.LastIndexOf("/")+1) + @"命令.bat";
if (File.Exists(file))
...{
StreamWriter sw = File.AppendText(file);
sw.WriteLine("net state");
sw.Close(); //关闭流
sw.Dispose(); //销假对象
}
else
...{
StreamWriter sw = File.CreateText(file);
sw.WriteLine("dir");
sw.Close();
sw.Dispose();
}
}
相关文章推荐
- C#-XML文件提取字符串+字符串存为XML文件+创建XML(自定义节点)文件+读取节点内容
- C# 如何创建一个xml文件?并写入指定内容?
- C# 如何创建一个xml文件?并写入指定内容?
- java创建文件相关内容
- asp.net c# mysql操作 之 从文件加载表内容
- C#创建自签名认证文件的方法
- .net,C#,Ftp各种操作,上传,下载,删除文件,创建目录,删除目录,获得文件列表等
- c#文件助手类分享(读取文件内容 操作日志文件)
- C#文件操作 追加、拷贝、删除、移动文件、创建目录 修改文件名、文件夹名
- C# 创建临时文件
- C#创建传输文件MD5验证码
- 前端使用c# winform创建客户端来进行post发送文件,后台使用java来接收
- 如何在C#中用程序执行指定的SQL脚本文件,实现自动安装创建数据库
- 手动创建两个文本文件text1.txt,text2.txt,要求编程创建text3.txt,实现text1.txt和text2.txt文件中除去首行和末尾,其余对应的数据相加,三个文本的内容如下
- IOS从.plist文件中读取内容,创建一个图片浏览器
- C#第十周任务之最后一项之创建一个如下的窗体,并在窗体上放置一个菜单、一个工具栏控件。菜单内容如第二个图所示。工具栏上有两个按钮,分别对应“打开文本文件”、“保存文本文件”。菜单和工具栏具体功能实现可
- c#实现根据有规律的文件内容解析成实体类
- 使用C#在程序运行时创建文件关联
- C# 通过word模板创建新文件
- C#创建DAT文件和读取DAT文件数据