title: Testing if a file/directory is read only
body: <p>okay, so I'm a bit of a C newbie. How does one test whether a file is read only on windows.</p>
  
  <p>I tried to get something working with the GetFileAttributes function, but to no avail.</p>
  
  <p>Given a file's path, what is the proper way to test if it is read only?</p>
  
  <p>Edit:</p>
  
  <p>So I'm still stuck on this one. I want to check if the user has permission to add and edit files in C:\Program Files... and I can't seem to get any of the advice to work.</p>
  
  <p>when I use !(GetFileAtrributes(path) &amp; FILE_ATTRIBUTES_READONLY), it indicates that the directory is not read only. I then tried to write a file and test if it worked:</p>
  
  <pre><code>strcat(path,"\\testFile000");
  FILE *test = 0;
  test = fopen(path,"w");
  int i = fwrite("ab",1,sizeof("ab"),test);
  </code></pre>
  
  <p>but when I do this test is non-null, i==3 and no file appears in the OS.</p>
  
  <p>Any ideas?</p>