[Mono-list] Re: Mono.Unix inside Mono.Posix?
Robert Jordan
robertj at gmx.net
Wed Aug 10 16:29:57 EDT 2005
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
More information about the Mono-list
mailing list