12 November 2011

File Creation Date and Time Conversion in C#


File Creation Date and Time Conversion in C#


using System;
using System.IO;
using System.Windows.Forms;

namespace ConvertDataTime
{
    public partial class ConvertDataandTime : Form
    {
        public ConvertDataandTime()
        {
            InitializeComponent();
        }

   
        private void btnConvert_Click(object sender, EventArgs e)
        {
            try
            {
                //"08/26/2011 15:00:00"
                FileSystemInfo f = new FileInfo(@txtPath.Text);
                f.CreationTime = Convert.ToDateTime(txtDateTime.Text);
                f.LastWriteTime = Convert.ToDateTime(txtDateTime.Text);
                f.LastAccessTime = Convert.ToDateTime(txtDateTime.Text);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            txtDateTime.Text = "08/26/2011 15:00:00";
            txtPath.Text="D:\\";
        }

     

     
    }
}


No comments:

Post a Comment

Comments Welcome