#region 写日志
private static void writelog(string strwrite)
{
string strPath = "d:/log.txt";
if (!File.Exists(strPath))
{
File.Create(strPath);
}
//定义写流对象
System.IO.StreamWriter writer = null;
//创建日志文件
string key = System.DateTime.Now.ToString("HH:mm:ss ") + strwrite;
try
{
//实例化流对象
writer = new StreamWriter(strPath, true);
//写信息
writer.WriteLine(key);
}
catch (Exception ex)
{

}
finally
{
//关闭流对象
if (writer != null)
{
writer.Flush();
writer.Close();
writer = null;
}
}
}
#endregion

写TXT文件的更多相关文章

  1. 【学习总结】GirlsInAI ML-diary day-15-读/写txt文件

    [学习总结]GirlsInAI ML-diary 总 原博github链接-day15 认识读/写txt文件 路径: 绝对路径:文件在电脑中的位置 相对路径:下面会用到 1-准备 新建一个 pytho ...

  2. C++文件处理(一):读/写txt文件

    C++文件处理与C语言不同,C++文件处理使用的是:流(stream) C++头文件fstream定义了三个类型来支持文件IO

  3. C#做一个写txt文件流的测试,为什么配置低的机器写入的还快

    测试机:笔记本i7 8G 固态硬盘 由于采取读码写入txt方式, 读码频率挺高,文件名为日期格式,当前采用每次读码打开文件写入的方式, 为什么没用sb,因为怕断电情况的数据丢失.所以采取每条存入的方式 ...

  4. .Net写txt文件-简单的记录执行日志信息代码

    在执行一些批量操作时,想记录一些执行日志信息,越简单方便越好啊.提供一个常用的简单方法,将信息记录在txt文件里: public static void log(string content, str ...

  5. matlab写txt文件

    fd=fopen('C:\Users\Qin\Desktop\1112.txt','w');for i=16:19 for j=1:5 fprintf(fd,'%f,%f\r\n',[cluster( ...

  6. python写txt文件

    with open('data.txt','w') as f: #设置文件对象 w是重新写,原来的会被抹掉,a+是在原来的基础上写 str0=u"写文件\n" #写中文要在字符串签 ...

  7. QT写TXT文件

    #include <QDir> //头文件 QDir *TEST = new QDir;    bool exist = TEST->exists("TEST") ...

  8. C# 读取网络txt文件 并写在本地txt文件中

    public void WriteStream() { try { stirng ImagesPath = ImagesPath + "\\2013-09-27.txt"; Htt ...

  9. Java写到.txt文件,如何实现换行

    http://blog.csdn.net/liangoo7/article/details/7882773 java中写.txt文件,实现换行的几种方法: 1.使用java中的转义符"\r\ ...

随机推荐

  1. k8s 部署kube-dns

    [root@k8s-master src]# kubectl create -f kube-dns.yaml service "kube-dns" createdserviceac ...

  2. [SHOI 2017] 分手是祝愿

    [题目链接] https://www.lydsy.com/JudgeOnline/problem.php?id=4872 [算法] 首先发现 , 对于一个开关 , 按下2次和没按是等价的 , 因此每个 ...

  3. C#如何把XSD中HexBinary类型序列化uint类型

    xml schema中有hexBinary类型, 我们在实现C#的Serialization时,一般默认把hexBinary映射为byte[],但是有些情况我们需要把 hexBinary映射为uint ...

  4. webAPP meta 标签大全

    1.先说说mate标签里的viewport: viewport即可视区域,对于桌面浏览器而言,viewport指的就是除去所有工具栏.状态栏.滚动条等等之后用于看网页的区域.对于传统WEB页面来说,9 ...

  5. AI-Info-Micron-Insight:Intelligence Accelerated™

    ylbtech-AI-Info-Micron-Insight:Intelligence Accelerated™ Intelligence Accelerated™ Micron Insight 大会 ...

  6. 九 Vue学习 manager页面布局

    1:  登录后系统页面如下: 对应代码: <template> <div class="manage_page fillcontain"> <el-r ...

  7. zoj3826 Hierarchical Notation (字符串模拟)

    Hierarchical Notation Time Limit: 2 Seconds      Memory Limit: 131072 KB In Marjar University, stude ...

  8. skb详细解析【转】

    skb详细解析[转]    摘自:http://blog.chinaunix.net/uid-30035229-id-4883992.html     在自己的模块发送函数中,需要对skb进行重新构造 ...

  9. unity3d GUI字体设置

    using System.Collections; using System.Collections.Generic; using UnityEngine; public class click001 ...

  10. EIP权限工作流平台-移动端