0
파일 검색을위한 코드와 여러 파일 확장자를 가진 파일을 검색하는 방법이 있습니다. Office 파일 {docx, pptx, xlsx, pdf}, 미디어 파일 {mp3 , mp4, mkv, avi}, 이미지 파일 {jpg, png}. 감사파일 확장자가 여러 개인 검색 파일
코드 :
public void SearchFile(string folder, string KeyWord, DataGridView TableName, ref Label Result, ref long Count)
{
string[] row;
foreach (string file in Directory.GetFiles(folder, "*" + KeyWord + "*doc")) // <== Multiple Extension Searching
{
FileInfo fi = new FileInfo(file);
double Lenght = fi.Length/1024;
row = new string[] { fi.Name, Lenght.ToString() + " KB", fi.LastAccessTime.Year.ToString(), fi.FullName };
TableName.Rows.Add(row);
number += 1;
}
foreach (string subDir in Directory.GetDirectories(folder))
{
try
{
SearchFile(subDir , KeyWord, TableName, ref Result, ref Count);
}
catch (UnauthorizedAccessException) { }
}
Count = Number;
Result.Text = "File Keyword '" + KeyWord + "', Not Found " + number.ToString() + " (file).";
}
나는 그것을 시험해 보았고 효과가 있었다. 감사 – user3425817