Aşağıdaki kod sDir kök dizininde verilen tüm dosyaları lstFounds adlı listeye atacaktır.
Burada recursionLv1 inilecek seviyeyi belirlmektedirAşağıdaki kod ise yukarıdakini belirlenen bir seviyeye kadar inerek yapmaktadır. Dosyaları ekrana basmaktadır
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 void DirSearch(string sDir)
{
try
{
foreach (string d in Directory.GetDirectories(sDir))
{Read More
foreach (string f in Directory.GetFiles(d, txtFile.Text))
{
lstFilesFound.Items.Add(f);
}
DirSearch(d);
}
}
catch (System.Exception excpt)
{
Console.WriteLine(excpt.Message);
}
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 public static void ProcessDir(string sourceDir, int recursionLvl) { if (recursionLvl<=HowDeepToScan) { // Process the list of files found in the directory. string [] fileEntries = Directory.GetFiles(sourceDir); foreach(string fileName in fileEntries) { // do something with fileName Console.WriteLine(fileName); } // Recurse into subdirectories of this directory. string [] subdirEntries = Directory.GetDirectories(sourceDir); foreach(string subdir in subdirEntries) // Do not iterate through reparse points if ((File.GetAttributes(subdir) & FileAttributes.ReparsePoint) != FileAttributes.ReparsePoint) ProcessDir(subdir,recursionLvl+1); } }
| < Önceki | Sonraki > |
|---|
Newer news items:
- 23/04/2010 07:42 - C kodu içerisinden Assembly çağırımı
- 03/04/2010 19:10 - Web Based Document Oriented Database
- 29/03/2010 08:11 - 2009 Yaz Stajı - Mecidiyeköy-Istanbul
- 28/03/2010 19:02 - Processes and Threads (Grid Computing Simulation)
Older news items:
- 10/12/2009 10:16 - Bil341_0910_Dosya ilgilerini elde etme
Site isminden de anlaşıldığı üzere ismim Mehmet Akif Akkuş. Hacettepe Uni. Biligisayar Muhendisliği öğrencisiyim. Osmaniyeliyim. Bu sayfa benim kişisel blog sayfamdır. Genellikle bilgisayar ve internet üzerine yazdığım şeylere buradan erişebilirsiniz. Benimle iletişim kurmak için












Yorumlar
http://null-pointerexception.blogspot.com/
RSS beslemesi, bu iletideki yorumlar için.