Mehmet Akif Akkus

Bir Bilgisayar Mühendisinin Günlüğü

Sunday, Aug 01st

Last update:04:49:41 AM GMT

Headlines:
RSS
You are here: Projeler Programlama Bil341_0910_Dosya ilgilerini elde etme

Bil341_0910_Dosya ilgilerini elde etme

e-Posta Yazdır PDF
Aşağıdaki kod ile dosya isimleri elde ediliyor
 
// Get an array of file names as strings rather than FileInfo objects.
// Use this method when storage space is an issue, and when you might
// hold on to the file name reference for a while before you try to access
// the file.
string[] files = System.IO.Directory.GetFiles(currentDirName, "*.txt");

foreach (string s in files)
{
// Create the FileInfo object only when needed to ensure
// the information is as current as possible.
System.IO.FileInfo fi = null;
try
{
fi = new System.IO.FileInfo(s);
}
catch (System.IO.FileNotFoundException e)
{
// To inform the user and continue is
// sufficient for this demonstration.
// Your application may require different behavior.
Console.WriteLine(e.Message);
continue;
}
Console.WriteLine("{0} : {1}",fi.Name, fi.Directory);
}

Yorum ekle


Güvenlik kodu
Yenile