文件时间伪造

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.Windows.Forms;

namespace FileTime
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form_DragEnter(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.FileDrop))    //判断拖来的是否是文件
                e.Effect = DragDropEffects.Link;                //是则将拖动源中的数据连接到控件
            else e.Effect = DragDropEffects.None;
        }

        private void Form_DragDrop(object sender, DragEventArgs e)
        {
            string filesName = "";
            Array file = (System.Array)e.Data.GetData(DataFormats.FileDrop);//将拖来的数据转化为数组存储

            //判断是否为目录,从目录载入文件
            if (file.Length == 1)
            {
                string str = file.GetValue(0).ToString();
                if (!System.IO.File.Exists(str) && System.IO.Directory.Exists(str)) //拖入的不是文件,是文件夹
                {
                    string[] files = System.IO.Directory.GetFiles(str);
                    for (int i = 0; i < files.Length; i++)
                        filesName += (files[i] + (i == files.Length - 1 ? "" : ";"));

                    textBox1.Text = filesName;
                }
            }

            //拖入的所有文件
            int len = file.Length;
            for (int i = 0; i < len; i++)
            {
                filesName += (file.GetValue(i).ToString() + (i == file.Length - 1 ? "" : ";"));
            }

            textBox1.Text = filesName;
        }

        private void Form_DragDrop1(object sender, DragEventArgs e)
        {
            string filesName1 = "";
            Array file = (System.Array)e.Data.GetData(DataFormats.FileDrop);//将拖来的数据转化为数组存储

            //判断是否为目录,从目录载入文件
            if (file.Length == 1)
            {
                string str = file.GetValue(0).ToString();
                if (!System.IO.File.Exists(str) && System.IO.Directory.Exists(str)) //拖入的不是文件,是文件夹
                {
                    string[] files = System.IO.Directory.GetFiles(str);
                    for (int i = 0; i < files.Length; i++)
                        filesName1 += (files[i] + (i == files.Length - 1 ? "" : ";"));

                    textBox2.Text = filesName1;
                }
            }

            //拖入的所有文件
            int len = file.Length;
            for (int i = 0; i < len; i++)
            {
                filesName1 += (file.GetValue(i).ToString() + (i == file.Length - 1 ? "" : ";"));
            }

            textBox2.Text = filesName1;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            FileInfo fi1 = new FileInfo(textBox1.Text);
            FileInfo fi2 = new FileInfo(textBox2.Text);

            fi2.CreationTime = fi1.CreationTime;
            fi2.LastAccessTime = fi1.LastAccessTime;
            fi2.LastWriteTime = fi1.LastWriteTime;
        }

    }
}

  

posted @ 2017-06-30 13:39 webappsec93 阅读(...) 评论(...) 编辑 收藏