using ryCommon; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using WeifenLuo.WinFormsUI.Docking; namespace 开发辅助工具.Tools { public partial class FrmFileTime : DockContent { public FrmFileTime() { InitializeComponent(); RyFiles.AddDropDrag(TxtPath.Handle).ElevatedDragDrop += FrmImageToIcon_ElevatedDragDrop; ; } private void FrmImageToIcon_ElevatedDragDrop(object sender, ElevatedDragDropArgs e) { LoadFile(e.Files[0]); } private void LoadFile(string path) { var dt = RyFiles.GetFileDate(path); dateTimePicker1.Value = dt.CreateTime; dateTimePicker2.Value=dt.LastWriteTime; TxtPath.Text = path; BtnConvert.Text = "立即修改"; } private void BtnBrowser_Click(object sender, EventArgs e) { if(openFileDialog1.ShowDialog()==DialogResult.OK) { LoadFile(openFileDialog1.FileName); } } private void BtnConvert_Click(object sender, EventArgs e) { var path = TxtPath.Text; if (!RyFiles.FileOrDirExist(path)) { MessageBox.Show("文件不存在", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } BtnConvert.Enabled = false; //superPictureBox1.Image = icon.ToBitmap(); BtnConvert.Text = "修改成功"; try { if(System.IO.File.Exists(path)) { FileInfo fileInfo = new FileInfo(path); fileInfo.CreationTime = dateTimePicker1.Value; fileInfo.LastWriteTime = dateTimePicker2.Value; } else if(System.IO.Directory.Exists(path)) { DirectoryInfo directoryInfo = new DirectoryInfo(path); directoryInfo.CreationTime = dateTimePicker1.Value; directoryInfo.LastWriteTime = dateTimePicker2.Value; } } catch { BtnConvert.Text = "修改失败"; } LoadFile(path); BtnConvert.Enabled = true; } } }