Дата создания и изменения файла

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

public class Example15_3 
{
    [STAThread]
  public static void Main() 
  {

    // create and show an open file dialog
    OpenFileDialog dlgOpen = new OpenFileDialog();
    if (dlgOpen.ShowDialog() == DialogResult.OK)
    {
      // use the File class to return info about the file
      string s = dlgOpen.FileName;
      Console.WriteLine("Filename " + s);
      Console.WriteLine(" Created at " + File.GetCreationTime(s));
      Console.WriteLine(" Accessed at " + 
       File.GetLastAccessTime(s));
    }
  }
}
Взято с http://www.java2s.com/Code/CSharp/File-Stream/GetfileCreationTime.htm

1 комментарий:

  1. 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;

    namespace WindowsFormsApplication1

    {

    public partial class Form1 : Form

    {

    public Form1()

    {

    InitializeComponent();

    }

    private void button1_Click(object sender, EventArgs e)

    {

    // create and show an open file dialog

    OpenFileDialog dlgOpen = new OpenFileDialog();

    if (dlgOpen.ShowDialog() == DialogResult.OK)

    {

    // use the File class to return info about the file

    string s = dlgOpen.FileName;

    richTextBox1.Text = "Filename " + s.ToString() + "\n" + "Created at " + File.GetCreationTime(s) + "\n" +

    "Accessed at " +

    File.GetLastAccessTime(s);

    }

    }

    private void richTextBox1_TextChanged(object sender, EventArgs e)

    {

    }

    }

    }

    ОтветитьУдалить

Большая просьба, не писать в комментариях всякую ерунду не по теме!