[問題] 檔案最後修改日期

看板C_Sharp作者 (年薪百萬前進(b))時間16年前 (2008/03/09 18:25), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
網址如下: http://www.wretch.cc/album/show.php?i=SuperAoi&b=31&f=1380611347&p=1 目前卡在.net並無支援FSO 希望能夠從一堆XLS檔抓取最後修改日期的一筆檔案 只差字串比較,但感覺並不是那麼好用 請問有相關方法可以用在屬性為:LastWriteTime的排序嗎? 程式碼如下: private void Button6_Click(object sender, System.EventArgs e) { ArrayList fileArray = new ArrayList(); string[] files; FileInfo info; this.ListBox1.Items.Clear(); this.ListBox2.Items.Clear(); //指定C:\Inetpub\wwwroot\DownLoad,取出所以副檔名為xls的檔案清單 files = Directory.GetFiles(Server.MapPath("/DownLoad"), "*.xls"); //fileArray.Sort(files,files.Length(), //將每一個檔案資訊加入ListBox1裡 foreach (string item in files) { info = new FileInfo(item); fileArray.Add(info); //將檔案名稱加入ListBox1 this.ListBox1.Items.Add(new ListItem(info.Name)); } //將檔案最後修改日加入ListBox2 //將排序後檔案最後修改日加入ListBox3 try { for (int i = 0; i <= files.GetUpperBound(0); i++) { string temp = Directory.GetLastWriteTime(files[0]).ToString(); TextBox1.Text = temp; DateTime dtWrite = Directory.GetLastWriteTime(files); ListBox3.Items.Add(temp); if (temp.CompareTo(Directory.GetLastWriteTime(files).ToString()) < 0) { this.ListBox3.Items.Clear(); ListBox3.Items.Add(Directory.GetLastWriteTime(files).ToString()); } ListBox2.Items.Add(dtWrite.ToString()); } } catch (IOException e1) { Console.WriteLine("Exception ", e1.Message.ToString()); } } -- 我的無名: http://www.wretch.cc/user/SuperAoi -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 125.231.150.159
文章代碼(AID): #17qxiIqv (C_Sharp)