Asp.net 定时写入文本记录

		public static string FileAddress = "c:\\TimerLog.txt";
protected void Page_Load(object sender, EventArgs e)
{
// 在应用程序启动时运行的代码
var myTimer = new System.Timers.Timer(60000);
myTimer.Elapsed += OnTimedEvent;
myTimer.Interval = 60000;
myTimer.Enabled = true;
} private static void OnTimedEvent(object source, System.Timers.ElapsedEventArgs e)
{
WriteString(DateTime.Now.ToString());
} public static void WriteString(string pPhone)
{
FileStream fs = null;
if (!File.Exists(FileAddress))
{
fs = new FileStream(FileAddress, FileMode.Create);
}
else
{
fs = new FileStream(FileAddress, FileMode.Append);
} StreamWriter sw = new StreamWriter(fs);
sw.WriteLine("—————————————————————————————–");
sw.WriteLine("日 期:" + DateTime.Now.ToString("G"));
sw.WriteLine("手机|内容|结果:" + pPhone);
sw.WriteLine("—————————————————————————————–");
sw.Close();
}

Asp.net 定时写入文本记录的更多相关文章

  1. WPF 定时写入文本

    public static void Start() { ThreadStart start = new ThreadStart(ThreadAction); Thread th = new Thre ...

  2. ASP.NET 定时通知

    ASP.NET 定时通知 using System; using System.Collections.Generic; using System.Linq; using System.Web; us ...

  3. ASP.NET Core使用Elasticsearch记录NLog日志

    ASP.NET Core使用Elasticsearch记录NLog日志 1.新建一个 ASP.NET Core项目 2.安装Nuge包 运行:Install-Package NLog.Web.AspN ...

  4. linux的fwrite()使用方法,当前时间写入文本的程序

    fwrite函数 1.函数功能 用来读写一个数据块. 2.一般调用形式 fwrite(buffer,size,count,fp); 3.说明 (1)buffer:是一个指针,对fread来说,它是读入 ...

  5. ASP.NET 配置KindEditor文本编辑器

    ASP.NET 配置KindEditor文本编辑器 跟着这篇博客做了两个小时,只搞出了下面这么个东西. 时间浪费在了原博客里这样的一句话:将kindeditor/asp.net/bin/LitJSON ...

  6. 关于 MAXScript 逐行写入文本

    官方帮助文档FileStream Values部分有相关介绍. fn format_txt filepath filetext = ( if doesFileExist filepath == tru ...

  7. python中文输出和写入文本

    中文输出 #-*-coding:utf8-*- import requests import re timeout = 8 headers = {'User-Agent':'Mozilla/5.0 ( ...

  8. C# 下载文件 删除文件 写入文本

    由于经常用到文件处理,便自己封装了下 分享给大家. 包含写入文本  批量删除文件  下载文件 .--可直接使用 /// <summary> /// 写入到txt /// </summ ...

  9. Python3.x:自动生成IP写入文本

    Python3.x:自动生成IP写入文本 ''' 生成ip写入文件 ''' import time time_start = time.time() #参数:number-生成条数:start-开始i ...

随机推荐

  1. 教程-Supports判断接口(Instance)是否支持

    function TCommandEnabledController.GetCommandVisible(const ACommandName: string): Boolean; var I: In ...

  2. PC问题-使用BAT方法清理Delphi临时文件

    @echo offdel /S *.~*del /S *.dcudel /S *.dskdel /S *.hppdel /S *.ddpdel /S *.mpsdel /S *.mptdel /S * ...

  3. hdoj 1234 开门人和关门人

    开门人和关门人 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) #include ...

  4. 备份数据表为insert 脚本

    unit Unit1; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System ...

  5. 转载 ASP.NET中如何取得Request URL的各个部分

    转载原地址 http://blog.miniasp.com/post/2008/02/10/How-Do-I-Get-Paths-and-URL-fragments-from-the-HttpRequ ...

  6. 转载LINQ TO Entity 在数据库发生更改时更新实体数据模型 .edmx 文件

    转载原出处:http://blog.csdn.net/litao2/article/details/8629335 在“模型浏览器”中,右击 .edmx 文件,然后选择“从数据库更新模型”. 模型更新 ...

  7. angular-tour 用户新手引导

    下载安装 bower install angular-tour 建立依赖,引入文件 <script src="bower_components/jquery/jquery.js&quo ...

  8. IOS开发常用技术网站

    IOS常用网站:    1.http://www.cocoachina.com    2.http://oschina.net    3.http://code4app.com

  9. mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication的解决方法

    直接命令行操作没有问题,但是PHP连接就会报上面的错误. SET old_passwords =0; USE mysql; UPDATE user SET password =PASSWORD('yo ...

  10. 修改LiteIDE 编辑窗口的主题

    用习惯了Visual Studio 再看其他编译器总是有点别扭,当然LiteIDE 也是能够自定义主题的,再次感叹作者的用心. 依次: 查看 -> 选项 -> LiteEditor 在编辑 ...