Asp.net 定时写入文本记录
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 定时写入文本记录的更多相关文章
- WPF 定时写入文本
public static void Start() { ThreadStart start = new ThreadStart(ThreadAction); Thread th = new Thre ...
- ASP.NET 定时通知
ASP.NET 定时通知 using System; using System.Collections.Generic; using System.Linq; using System.Web; us ...
- ASP.NET Core使用Elasticsearch记录NLog日志
ASP.NET Core使用Elasticsearch记录NLog日志 1.新建一个 ASP.NET Core项目 2.安装Nuge包 运行:Install-Package NLog.Web.AspN ...
- linux的fwrite()使用方法,当前时间写入文本的程序
fwrite函数 1.函数功能 用来读写一个数据块. 2.一般调用形式 fwrite(buffer,size,count,fp); 3.说明 (1)buffer:是一个指针,对fread来说,它是读入 ...
- ASP.NET 配置KindEditor文本编辑器
ASP.NET 配置KindEditor文本编辑器 跟着这篇博客做了两个小时,只搞出了下面这么个东西. 时间浪费在了原博客里这样的一句话:将kindeditor/asp.net/bin/LitJSON ...
- 关于 MAXScript 逐行写入文本
官方帮助文档FileStream Values部分有相关介绍. fn format_txt filepath filetext = ( if doesFileExist filepath == tru ...
- python中文输出和写入文本
中文输出 #-*-coding:utf8-*- import requests import re timeout = 8 headers = {'User-Agent':'Mozilla/5.0 ( ...
- C# 下载文件 删除文件 写入文本
由于经常用到文件处理,便自己封装了下 分享给大家. 包含写入文本 批量删除文件 下载文件 .--可直接使用 /// <summary> /// 写入到txt /// </summ ...
- Python3.x:自动生成IP写入文本
Python3.x:自动生成IP写入文本 ''' 生成ip写入文件 ''' import time time_start = time.time() #参数:number-生成条数:start-开始i ...
随机推荐
- Android实例-处理隐藏输入法后不再显示问题(XE8+小米2)
结果: 1.可以处理再次显示问题,但缺点是每个控件都要处理一次,累.哪位大神有好的处理方法,请M我. 实例代码: unit Unit1; interface uses System.SysUtils, ...
- hdoj 2817 A sequence of numbers【快速幂】
A sequence of numbers Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Ot ...
- Windbg分析DMP文件
1.提取Dump格式文件 有两种方式: 第一种,程序崩溃时,启动任务管理器,选择崩溃的*.exe进程,右键选择创建转储文件,通过 开始—运行—输入 %temp% --确定--在打开Temp窗口中即可找 ...
- hql注意事项一
Space is not allowed after parameter prefix ':' [from EmPaperCatalogDef e where e.parentId =: pcdId]
- C#基础系列(一)
1.vs中F5(调试)和Ctrl + F5(直接运行不调试)的区别: Ctrl+F5是直接运行生成的程序,不进行重新编绎,所以运行起来比较快F5是重新编绎后再运行,这样可以在程序代码中设置断点跟踪来调 ...
- position绝对剧中
function loginH(){ var loginH = $('.sign-main-bg .sign-main-content'); var h = loginH.height(); logi ...
- Ms SQL Server 约束和规则
一.SQL约束 约束定义关于列中允许值的规则,是强制完整性的标准机制. 使用约束优先于使用触发器.规则和默认值.查询优化器也使用约束定义生成高性能的查询执行计划. 1:类型 约束的类型一共分三种 域约 ...
- 在Win8 Mertro 中使用SQLite
在Win8 Mertro 中使用SQLite 分类: .net 开发 2012-09-19 18:17 1229人阅读 评论(3) ...
- C/C++中的变量作用域
#include <iostream> using namespace std; int i = 1;int j = 2; int main(){ int i = 9; //C/ ...
- mysql之union
今天来写写union的用法及一些需要注意的. union:联合的意思,即把两次或多次查询结果合并起来. 要求:两次查询的列数必须一致 推荐:列的类型可以不一样,但推荐查询的每一列,想对应的类型以一样 ...