複製特定的檔案作備份 為朋友開發的小程式

2021-04-09 09:49:47 字數 1858 閱讀 5425

//功能:問題描述:

//有一目錄下有三個資料夾:

//分別為:awssource、basedata、log

//檔案組織形式如下:

//d:/2004/awssource

//  p5875009.006(每天會更新,檔名每月更改一次)如:p5875010.006

//  z5875009.006((每天會更新,檔名每月更改一次)如:z5875010.006

//  w5875009.006((每天會更新,檔名每月更改一次)如:w5875010.006

//  zz.txt

//  fj.txt

//  hh.txt

//  ............

//d:/2004/log

// 20060901.log(每天乙個)如今天的檔名為:20061003.log

// nf20060901.log(每天乙個)如今天的檔名為:nf20061003.log

// //這幾個資料夾下還有其它很多檔案,我想每次拷貝這幾個目錄下最新的特定的檔案(隨時間不同檔名也會發生//變化)作為備份,請各位高手指教。

using system;

using system.collections.generic;

using system.componentmodel;

using system.data;

using system.drawing;

using system.text;

using system.windows.forms;

using system.io;

using system.windows.forms.design;

namespace bckfile

public class folderdialog : foldernameeditor //新建乙個folderdialog類,此類從foldernameeditor類繼承

public dialogresult displaydialog()

public dialogresult displaydialog(string description)

public string path

}~folderdialog()

} private void createnewdir(string path) //在目標碟符裡建立資料夾

else

private void button1_click(object sender, eventargs e) //「開始備份」按鈕事件

private void button2_click(object sender, eventargs e) //「開啟備份路徑」按鈕事件

else

}public void copyfiles(string varfromdirectory, string vartodirectory)

string directories = directory.getdirectories(varfromdirectory);//取資料夾下所有資料夾名,放入陣列;

if (directories.length > 0)

}string files = directory.getfiles(varfromdirectory);//取資料夾下所有檔名,放入陣列;

if (files.length > 0)

}catch(ioexception iex)}}

}}

private void button3_click(object sender, eventargs e)//開啟需要備份的路徑

else

}// private bool comparefilename()//}

查詢特定字尾的檔案

coding cp936 python 27 xiaodeng 查詢特定字尾的檔案 方法一 importos os.listdir,獲取指定目錄下的內容 返回乙個list 該目錄下所有的內容都將被返回 import osdef filetype filename,args for types in ...

查詢特定字尾的檔案

coding cp936 python 27 xiaodeng 查詢特定字尾的檔案 方法一 importos os.listdir,獲取指定目錄下的內容 返回乙個list 該目錄下所有的內容都將被返回 import osdef filetype filename,args for types in ...

使用Robocopy複製 備份檔案夾

robocopy 是微軟提供的命令列複製工具,有非常豐富的引數供選擇。當要操作大量的檔案複製和資料夾備份,免費工具中,robocopy 是不二之選。有些遺憾的是,我還沒發現 robocopy 可以有不覆蓋目標目錄檔案的功能。如果複製過程中網路中斷,只能再從頭來過。robocopy 能夠提供的特色功能...