jigily
چهارشنبه 21 فروردین 1392, 15:08 عصر
من میخوام فایل عکس را از درون پوشه ای که ذخیره شده حذف کنم از چه کدی استفاده کنم؟
jigily
پنج شنبه 12 اردیبهشت 1392, 06:12 صبح
کسی کد نداره؟
fakhravari
پنج شنبه 12 اردیبهشت 1392, 10:34 صبح
file.delete
jigily
سه شنبه 17 اردیبهشت 1392, 05:45 صبح
میشه بیشتر توضیح بدید
hesam_a110
سه شنبه 17 اردیبهشت 1392, 07:21 صبح
using System.IO;
string[] filePaths = Directory.GetFiles(@"c:\yourDir\");
foreach (string filePath in filePaths)
File.Delete(filePath);
همون کد تویه یه خط
Array.ForEach(Directory.GetFiles(@"c:\yourDIr\"),
delegate(string path) { File.Delete(path); });
---------------------------------
if(System.IO.File.Exists(@"C:\test.txt"))
{
// Use a try block to catch IOExceptions, to
// handle the case of the file already being
// opened by another process.
try
{
System.IO.File.Delete(@"C:\test.txt");
}
catch (System.IO.IOException e)
{
Console.WriteLine(e.Message);
return;
}
}
یادتون باشه که using System.IO; رو اضافه کنید :)
پیروز باشید
vBulletin® v4.2.5, Copyright ©2000-1403, Jelsoft Enterprises Ltd.