Пример #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                OpenFileDialog openFileDialog = new OpenFileDialog();
                openFileDialog.InitialDirectory = @".//";
                openFileDialog.Title            = "请选择要打开的文件";
                openFileDialog.Filter           = "所有文件|*.*";
                string filepath = "";
                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    filepath      = openFileDialog.FileName.ToString();
                    textBox1.Text = filepath;
                    FileInfo fileInfo = new FileInfo(filepath);
                    CreateDateTime = fileInfo.CreationTime;
                    AccessDateTime = fileInfo.LastAccessTime;
                    ModifyDateTime = fileInfo.LastWriteTime;

                    textBox2.Text        = CreateDateTime.ToString();
                    dateTimePicker1.Text = textBox2.Text;

                    CreateTimeStamp = ConvertDateTimeToInt(CreateDateTime);
                    AccessTimeStamp = ConvertDateTimeToInt(AccessDateTime);
                    ModifyTimeStamp = ConvertDateTimeToInt(ModifyDateTime);

                    textBox3.Text        = AccessDateTime.ToString();
                    dateTimePicker2.Text = textBox3.Text;
                    textBox4.Text        = ModifyDateTime.ToString();
                    dateTimePicker3.Text = textBox4.Text;
                }
            }
            catch (System.UnauthorizedAccessException)
            {
                MessageBox.Show("打开失败,请检查权限");
            }
            catch (Exception e1)
            {
                MessageBox.Show(e1.ToString());
            }
        }
Пример #2
0
        private void button6_Click(object sender, EventArgs e)
        {
            string filepath = textBox1.Text;

            textBox1.Text = filepath;
            FileInfo fileInfo = new FileInfo(filepath);

            CreateDateTime = fileInfo.CreationTime;
            AccessDateTime = fileInfo.LastAccessTime;
            ModifyDateTime = fileInfo.LastWriteTime;

            textBox2.Text        = CreateDateTime.ToString();
            dateTimePicker1.Text = textBox2.Text;

            CreateTimeStamp = ConvertDateTimeToInt(CreateDateTime);
            AccessTimeStamp = ConvertDateTimeToInt(AccessDateTime);
            ModifyTimeStamp = ConvertDateTimeToInt(ModifyDateTime);

            textBox3.Text        = AccessDateTime.ToString();
            dateTimePicker2.Text = textBox3.Text;
            textBox4.Text        = ModifyDateTime.ToString();
            dateTimePicker3.Text = textBox4.Text;
        }