Example #1
0
        /// <summary> Removes a file by UNC path </summary>
        /// <param name="path">Path to the file to remove</param>
        public static void DeleteFileUnc(String path)
        {
            bool result     = Win32SafeNativeMethods.DeleteFile(path);
            int  win32Error = Marshal.GetLastWin32Error();

            if (!result)
            {
                NativeExceptionMapping(path, win32Error);
            }
        }
Example #2
0
        /// <summary>
        /// Removes a file.
        /// </summary>
        /// <param name="path">Path to the file to remove</param>
        /// <exception cref="FileNotFoundException">This error is fired if the specified file to remove does not exist.</exception>
        public static void DeleteFile(String path)
        {
            Contract.Requires(!String.IsNullOrWhiteSpace(path));

            // Remove all attributes
            RemoveAllFileAttributes(path);

            if (!Win32SafeNativeMethods.DeleteFile(path))
            {
                Win32ErrorCodes.NativeExceptionMapping(path, Marshal.GetLastWin32Error());
            }
        }