Directory sinfidan foydalanish Directory sinfining metodlari va ular bilan ishlash 6


Download 0.55 Mb.
bet12/14
Sana28.12.2022
Hajmi0.55 Mb.
#1013966
1   ...   6   7   8   9   10   11   12   13   14
Bog'liq
Dasturlash asoslari fanidan C# dasturlash tilining Directory,

foreach (DirectoryInfo dri in diArr)
Console.WriteLine("\t" +dri.Name);
Console.ReadKey();
}
}
Natijasi:

EnumerateDirectories() – joriy katalogdagi ma'lumotlarni sanaydigan to'plamni qaytaradi.
Foydalanish misoli:
using System;
using System.IO;
using System.Linq;
namespace EnumDir
{
class Program
{
static void Main(string[] args)
{
string docPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
DirectoryInfo dirPrograms = new DirectoryInfo(docPath);
DateTime StartOf2019 = new DateTime(2019, 12, 04);
var dirs = from dir in dirPrograms.EnumerateDirectories()
where dir.CreationTimeUtc > StartOf2019
select new
{
ProgDir = dir,
};
Console.WriteLine("(2019, 12, 04) sanadan boshlab yaratilgan kataloglar ro'yxati:"+"\n");
foreach (var di in dirs)
{
Console.WriteLine(di.ProgDir.Name);
}
Console.ReadKey();
}
}
}
Natijasi:

EnumerateDirectories(String) – belgilangan yo’lda qidirish namunasiga mos keladigan katalogning to’liq nomlarini sanaydigan to’plamni qaytaradi.
Foydalanish misoli:
Public System.Collections.Generic.IEnumerable
EnumerateDirectories (string searchPattern);
EnumerateDirectories(String, SearchOption) – belgilangan yo’lda qidirish namunasiga mos keladigan katalogning to’liq nomlarini sanaydigan to’plamini va ixtiyoriy ravishda qidirilgan pastki kataloglarni qaytaradi.
Foydalanish misoli:
public System.Collections.Generic.IEnumerable
EnumerateDirectories (string searchPattern, SearchOption searchOption);
MoveTo() – DirectoryInfo nusxasini va uning tarkibini yangi yo'lga ko'chiradi.
Foydalanish misoli:

Download 0.55 Mb.

Do'stlaringiz bilan baham:
1   ...   6   7   8   9   10   11   12   13   14




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling