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实例-MotionSensor加速度(XE8+小米2)
结果: 1. 实例代码: unit Unit1; interface uses System.SysUtils, System.Types, System.UITypes, System.Classe ...
- DTD - XML Building Blocks
The main building blocks of both XML and HTML documents are elements. The Building Blocks of XML Doc ...
- MSSQLSERVER数据库- 一条代码搞定单表备份表结构和表数据
在百度上找到的,很实用这个容易操作,不就两张表,我的建议就是备份表带上日期,以便以后要恢复数据的时候,可以快速找到他,这样备份是表结构和数据一起处理.select * into share_20090 ...
- 如何关闭log4j中配置的spring或者hibernate的日志信息
通常在建立一个web项目的时候,我们通常需要为其配置日志,以便了解启动过程中发生了什么,如果启动过程中发生了错误,则可以很方便的查看错误的信息,但是在项目部署到服务器上时,打印日志信息,需要耗费大量的 ...
- hadoop安装与WordCount例子
1.JDK安装 下载网址: http://www.oracle.com/technetwork/java/javase/downloads/jdk-6u29-download-513648.html ...
- jQuery生成二维条形码 jquery.qrcode.js
国内私募机构九鼎控股打造APP,来就送 20元现金领取地址:http://jdb.jiudingcapital.com/phone.html内部邀请码:C8E245J (不写邀请码,没有现金送)国内私 ...
- android自动填充短信验证码
自动拦截短信实际上就是在系统注册一个BroadcastReceiver,然后通过设置拦截短信的: filter.addAction("android.provider.Telephony.S ...
- 学习笔记之Linux开发(C语言)
第二章 Linux下C程序开发环境 vi编辑器 gcc 第三章 Linux基础 Kernel Shell 第三章 Linux技术实验 ls -l 以长格式的形式查看当前目录下所有可见文件的详细属性. ...
- PAT 1005
1005. Spell It Right (20) Given a non-negative integer N, your task is to compute the sum of all the ...
- WebKit笔记
加载网页时执行javascript代码 let mWebView = WKWebView.init(frame: self.view.bounds) self.view.addSubview(mWeb ...