2010-10-21 31 views

cevap

49

izlemeyi deneyin.

DirectoryInfo di = 
    new DirectoryInfo("Path"); 
FileInfo[] files = 
    di.GetFiles("*.*", SearchOption.AllDirectories); 

foreach (FileInfo f in files) 
    f.MoveTo("newPath"); 
+2

Teşekkür, Bu siteyi seviyorum)) cevabı almak için 1 dk. –

+7

Rica ederim. Zaten yapacak daha iyi bir şey yok (bilirsin: iş). Sorununuzu görmek için –

+0

çok kişi :), Toplu İstihbarat – TalentTuner

10

kullanım DirectoryInfo ve dosya bilgilerini ve Dizin, onlar daha gelişmiş özellikler sunmayı:

string newPath = "C:\\NewPath"; 

string[] filePaths = Directory.GetFiles(_configSection.ImportFilePath); 
foreach (string filePath in filePaths) 
{ 
    // extract file name and add new path 
    File.Delete(filePath); 
} 
4

Böyle yapabilirsiniz:

string newPath = "C:\\NewPath"; 
string[] filePaths = Directory.GetFiles(_configSection.ImportFilePath); 
foreach (string filePath in filePaths) 
{ 
    string newFilePath = Path.Combine(newPath, Path.GetFileName(filePath); 
    File.Move(filePath, newFilePath); 
}