An exception that occurs when trying to access an object for which you don't have the correct security authorization. For example, trying to access a file that doesn't allow read access by your user.
An exception that occurs when trying to access an object for which you don't have the correct security authorization.
This could occur as a result of many different actions, such as...
- Trying to perform an operation on a file, but you don;t have the appropriate security authorizations. For example, trying to write to a file that only allows read access.
- Trying to open a connection to a remote server, but specifying the incorrect login details. For example, trying to open a Socket, or communication to a Telnet or FTP server.
Your code should be able to prevent or handle this type of exception...
- Detect - Before performing any file operations, check the authorization permissions on the file, to see whether you are able to perform the desired operation. If not, you can perform an alternate operation, such as alerting the user of the error, or trying to access files in a different location of the file system instead.
- Handle - Wrap your file and communication interactions in exception-handling code, such as a try-catch block. This will allow you to catch unexpected exceptions such as this, and perform an alternate operation, such as alerting the user of the error.