How to check whether a file has a ReadOnly Attribute or not?

 Posted by vishalneeraj-24503 on 11/12/2014 | Category: Visual Studio Interview questions | Views: 625 | Points: 40
Answer:

We will write below code to check whether a file has a ReadOnly Attribute or not:-
if(((File.GetAttributes("file_path") & FileAttributes.ReadOnly) == FileAttributes.ReadOnly))

{
return true;
}
return false;


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response