Esempio n. 1
0
        /// <summary>
        ///     Returns the handle by given path and finddata
        /// </summary>
        /// <param name="uncPath">Specified path</param>
        /// <param name="win32FindData">FindData to fill</param>
        /// <param name="win32Error">Win32Error Code. 0 on success</param>
        /// <returns><see cref="Win32FileHandle" /> of specified path</returns>
        static Win32FileHandle FindFirstFileManaged(String uncPath, Win32FindData win32FindData, out Int32 win32Error)
        {
            var handle = Win32SafeNativeMethods.FindFirstFile(uncPath, win32FindData);

            win32Error = Marshal.GetLastWin32Error();
            return(handle);
        }
Esempio n. 2
0
        /// <summary>
        ///     Returns the <see cref="SafeFileHandle" /> and fills <see cref="Win32FindData" /> from the passes path.
        /// </summary>
        /// <param name="path">Path to the file system entry</param>
        /// <param name="win32FindData"></param>
        /// <param name="win32Error">Last error code. 0 if no error occurs</param>
        /// <returns>
        ///     <see cref="SafeFileHandle" />
        /// </returns>
        static Win32FileHandle FindFirstSafeFileHandle(string path, Win32FindData win32FindData, out Int32 win32Error)
        {
            var result = Win32SafeNativeMethods.FindFirstFile(path, win32FindData);

            win32Error = Marshal.GetLastWin32Error();

            return(result);
        }
Esempio n. 3
0
        /// <summary>
        /// Returns the <see cref="Win32FileHandle"/> and fills <see cref="Win32FindData"/> from the passes path.
        /// </summary>
        /// <param name="path">Path to the file system entry</param>
        /// <param name="win32FindData"></param>
        /// <param name="win32Error">Last error code. 0 if no error occurs</param>
        /// <returns><see cref="Win32FileHandle"/></returns>
        /// <exception cref="PathNotFoundException">This error is fired if the specified path or a part of them does not exist.</exception>
        private static Win32FileHandle FindFirstSafeFileHandle(string path, Win32FindData win32FindData, out Int32 win32Error)
        {
            Contract.Requires(!String.IsNullOrWhiteSpace(path));

            Contract.Ensures(Contract.Result <Win32FileHandle>() != null);

            var result = Win32SafeNativeMethods.FindFirstFile(path, win32FindData);

            win32Error = Marshal.GetLastWin32Error();

            return(result);
        }