Beispiel #1
0
        /// <include file='doc\DirectoryEntry.uex' path='docs/doc[@for="DirectoryEntry.Exists"]/*' />
        /// <devdoc>
        ///    <para>
        ///       Searches the directory store at the given
        ///       path to see whether an entry exists.
        ///    </para>
        /// </devdoc>
        public static bool Exists(string path)
        {
            DirectoryEntry entry = new DirectoryEntry(path);

            try {
                entry.Bind(true);       // throws exceptions (possibly can break applications)
                return(entry.Bound);
            }
            catch (System.Runtime.InteropServices.COMException e) {
                if (e.ErrorCode == unchecked ((int)0x80072030))    // ERROR_DS_NO_SUCH_OBJECT (not found in strict sense)
                {
                    return(false);
                }
                throw;
            }
            finally {
                entry.Dispose();
            }
        }
        public static bool Exists(string path)
        {
            bool           bound;
            DirectoryEntry entry = new DirectoryEntry(path);

            try
            {
                entry.Bind(true);
                bound = entry.Bound;
            }
            catch (COMException exception)
            {
                if (((exception.ErrorCode != -2147016656) && (exception.ErrorCode != -2147024893)) && (exception.ErrorCode != -2147022676))
                {
                    throw;
                }
                bound = false;
            }
            finally
            {
                entry.Dispose();
            }
            return(bound);
        }
Beispiel #3
0
 /// <include file='doc\DirectoryEntry.uex' path='docs/doc[@for="DirectoryEntry.Exists"]/*' />
 /// <devdoc>
 ///    <para>
 ///       Searches the directory store at the given
 ///       path to see whether an entry exists.
 ///    </para>
 /// </devdoc>        
 public static bool Exists(string path)
 {
     DirectoryEntry entry = new DirectoryEntry(path);
     try
     {
         entry.Bind(true);       // throws exceptions (possibly can break applications) 
         return entry.Bound;
     }
     catch (System.Runtime.InteropServices.COMException e)
     {
         if (e.ErrorCode == unchecked((int)0x80072030) ||
              e.ErrorCode == unchecked((int)0x80070003) ||   // ERROR_DS_NO_SUCH_OBJECT and path not found (not found in strict sense)
              e.ErrorCode == unchecked((int)0x800708AC))     // Group name could not be found
             return false;
         throw;
     }
     finally
     {
         entry.Dispose();
     }
 }
 public static bool Exists(string path)
 {
     bool bound;
     DirectoryEntry entry = new DirectoryEntry(path);
     try
     {
         entry.Bind(true);
         bound = entry.Bound;
     }
     catch (COMException exception)
     {
         if (((exception.ErrorCode != -2147016656) && (exception.ErrorCode != -2147024893)) && (exception.ErrorCode != -2147022676))
         {
             throw;
         }
         bound = false;
     }
     finally
     {
         entry.Dispose();
     }
     return bound;
 }