user84
user84

Reputation: 11

Identify If Access database having ReadOnly Permission

Thanks

Upvotes: 1

Views: 653

Answers (2)

Daniel Mošmondor
Daniel Mošmondor

Reputation: 19956

As far as I can remember, Access can deny you writes despite the fact that database file is writable.

Best way to check it is to try to insert some dummy value right after opening the database. Catch the exception and inform the user.

Upvotes: 1

Ta01
Ta01

Reputation: 31610

You can use FileInfo

FileInfo f = new FileInfo(@"C:\MyDb.accdb");
if (f.IsReadOnly)
{
    Console.WriteLine("File is Read only");
}
else
{
    Console.WriteLine("File is Not Read Only");
}

Upvotes: 1

Related Questions