取得資料夾用Directory
寫法如下
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 GetTime
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button_OpenFile_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "標準文字檔|*.txt";
if (ofd.ShowDialog() == DialogResult.OK)
{
MessageBox.Show("檔案最後修改時間:" + File.GetLastWriteTime(ofd.FileName).ToString());
}
}
private void button_OpenFolder_Click(object sender, EventArgs e)
{
FolderBrowserDialog fbd = new FolderBrowserDialog();
if (fbd.ShowDialog() == DialogResult.OK)
{
MessageBox.Show("資料夾最後寫入時間:" + Directory.GetLastWriteTime(fbd.SelectedPath).ToString());
}
}
}
}
參考資料:
http://www.blueshop.com.tw/board/show.asp?subcde=BRD200904281757588SO
http://www.dotblogs.com.tw/chou/archive/2011/05/31/26664.aspx
http://takamai.pixnet.net/blog/post/38394731
http://www.programmer-club.com/ShowSameTitleN/csharp/9680.html



