小程序--修改文件的最后修改日期
2011-07-14 15:44 zhoujie 阅读(484) 评论(0) 收藏 举报经常遇到要修改文件的最后修改日期的情况,于是用C#写了一个备用。
代码很简单:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace 修改日期
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
using (OpenFileDialog ofd=new OpenFileDialog())
{
if (ofd.ShowDialog() == DialogResult.OK)
{
this.textBox1.Text = ofd.FileName;
}
}
}
private void button2_Click(object sender, EventArgs e)
{
System.IO.File.SetLastWriteTime(this.textBox1.Text, DateTime.Parse(textBox2.Text));
MessageBox.Show("修改成功");
}
}
}
浙公网安备 33010602011771号