Пример #1
0
        /// <summary>
        /// Reurns true if passed path exists
        /// </summary>
        /// <param name="path">Path to check</param>
        public static Boolean Exists(String path)
        {
            Contract.Requires(!String.IsNullOrWhiteSpace(path));

            uint attributes = Win32SafeNativeMethods.GetFileAttributes(path);

            return(!Equals(attributes, 0xffffffff));
        }
Пример #2
0
        /// <summary>
        /// Gets the <see cref="FileAttributes"/> of the file on the entry.
        /// </summary>
        /// <param name="path">The path to the entry. </param>
        /// <param name="win32Error">Win32 Error Code</param>
        /// <returns>The <see cref="FileAttributes"/> of the file on the entry.</returns>
        /// <exception cref="PathNotFoundException">This error is fired if the specified path or a part of them does not exist.</exception>
        internal static uint SafeGetAttributes(String path, out Int32 win32Error)
        {
            Contract.Requires(!String.IsNullOrWhiteSpace(path));

            uint attributes = Win32SafeNativeMethods.GetFileAttributes(path);

            win32Error = (attributes) == 0xffffffff ? Marshal.GetLastWin32Error() : 0;
            return(attributes);
        }
Пример #3
0
        /// <summary>
        ///     Reurns true if passed path exists
        /// </summary>
        /// <param name="pathInfo">Path to check</param>
        public static Boolean Exists(PathInfo pathInfo)
        {
            uint attributes = Win32SafeNativeMethods.GetFileAttributes(pathInfo.FullNameUnc);

            return(!Equals(attributes, 0xffffffff));
        }