zimmer9
asked on
What statement would you code to delete all files in the following directory that have a file extension of *.TIF ?
I am writing a C# application using VS2010 and .Net Framework 4.0.
What statement would you code to delete all files in the following directory that have a file extension of *.TIF ?
I use the following value for the directory path:
const string TARGET_DIR_IN = @"\\v\region\na\control\de v\W\data\T est1\";
What statement would you code to delete all files in the following directory that have a file extension of *.TIF ?
I use the following value for the directory path:
const string TARGET_DIR_IN = @"\\v\region\na\control\de
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Correct code
DirectoryInfo di = new DirectoryInfo(TARGET_DIR_IN);
FileInfo[] files = di.GetFiles("*.TIF")
.Where(p => p.Extension == ".TIF").ToArray();
foreach (FileInfo file in files)
try
{
file.Attributes = FileAttributes.Normal;
File.Delete(file.FullName);
}
catch { }
pls try
Open in new window
Regards