System.Configuration.Internal.WriteFileContext.ValidateWriteAccess C# (CSharp) Метод

ValidateWriteAccess() приватный Метод

private ValidateWriteAccess ( string filename ) : void
filename string
Результат void
        private void ValidateWriteAccess( string filename ) {
            FileStream fs = null;

            try {
                // Try to open file for write access
                fs = new FileStream( filename,
                                     FileMode.Open,
                                     FileAccess.Write,
                                     FileShare.ReadWrite );
            }
            catch ( UnauthorizedAccessException ) {
                // Access was denied, make sure we throw this
                throw;
            }
            catch ( IOException ) {
                // Someone else was using the file.  Since we did not get
                // the unauthorizedAccessException we have access to the file
            }
            catch ( Exception ) {
                // Unexpected, so just throw for safety sake
                throw;
            }
            finally {
                if ( fs != null ) {
                    fs.Close();
                }
            }
        }