[Mono-list] Re: Mono.Unix inside Mono.Posix?

Bob Portmann bportmann at yahoo.com
Wed Aug 10 18:51:40 EDT 2005


OK, File.Exists would work for me (since I know already that the file
exists).  Is there an advantage of using File.Exists over
Mono.Unix.access?  For example, does Mono.Unix.access work on Windows?

--- Robert Jordan <robertj at gmx.net> wrote:

> Bob,
> 
> > Question 2: Actually, the only method I need (so far) is 
> > Mono.Unix.access to find out if a file has read access.  Is there a
> 
> > way to find this out using a method in System.
> 
> File.Exists (path) should return false when "path" isn't
> readable. However, it also returns false when "path" doesn't
> exist.
> 
> If speed doesn't count, you may try to read the file while
> catching the exception:
> 
> bool IsReadable (path)
> {
>      try {
>          File.OpenRead (fileName).Close ();
>          return true;
>      }
>      catch (UnauthorizedAccessException) {
>          return false;
>      }
> }
> 
> If both cases are inacceptable, then you have to use
> Mono.Unix.access.
> 
> Rob


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


More information about the Mono-list mailing list