PDA

View Full Version : ایجاد فولدر



hadiM18
سه شنبه 03 شهریور 1388, 00:19 صبح
سلام
چطوری میشه هنگام لود برنامه توی آدرسی که از قبل مشخص کردیم(مثلا درایو D )
اول بررسی کنیم که اگه پوشه ای به اسم New Folder وجود نداشت ، یک New Folder بسازه
لطفا راهنماییم کنید
ممنون

Saeed.Masoumi
سه شنبه 03 شهریور 1388, 00:32 صبح
if (!System.IO.Directory.Exists(@"d:\new folder"))
System.IO.Directory.CreateDirectory(@"d:\new folder");

Open-Source
سه شنبه 03 شهریور 1388, 12:15 عصر
حالا چطوری میشه پوشه ای رو که میسازیم hiddein و سیستمی کنیم؟!

Saeed.Masoumi
سه شنبه 03 شهریور 1388, 15:25 عصر
سلام



if (!System.IO.Directory.Exists(@"d:\x"))
{
System.IO.Directory.CreateDirectory(@"d:\x");
System.IO.DirectoryInfo di = new DirectoryInfo(@"d:\x");
di.Attributes = System.IO.FileAttributes.Hidden;
di.Attributes = System.IO.FileAttributes.ReadOnly;
di.Attributes = System.IO.FileAttributes.System;
di.Attributes = System.IO.FileAttributes.Archive;
}
else
{
System.IO.DirectoryInfo di = new DirectoryInfo(@"d:\x");
di.Attributes = System.IO.FileAttributes.Hidden;
di.Attributes = System.IO.FileAttributes.ReadOnly;
di.Attributes = System.IO.FileAttributes.System;
di.Attributes = System.IO.FileAttributes.Archive;
}

system32
سه شنبه 03 شهریور 1388, 16:42 عصر
در ضمن برای اینکه عمل تغییر خاصیت همان موقع اعمال شود از متد Refresh استفاده کنید. به این دو جمله از MSDN توجه کنید:




Calls must be made to Refresh before attempting to get the attribute information, or the information will be outdated.




Refreshes the state of the object.