public void
Delete_file_ReadonlyCondition(string FilePath)
{
//// Set file permission to delete
file
FileAttributes attributes =
File.GetAttributes(FilePath);
if ((attributes & FileAttributes.ReadOnly) ==
FileAttributes.ReadOnly)
{
attributes &=
~FileAttributes.ReadOnly;
File.SetAttributes(FilePath,
attributes);
File.Delete(FilePath);
}
else
{
FileInfo f = new FileInfo(FilePath);
if (f.Exists)
{
File.SetAttributes(FilePath, FileAttributes.Normal);
File.Delete(FilePath);
}
}
}
No comments:
Post a Comment