public static void SetFileAttributes(string filePath, FileAttributes attributes) { filePath = CheckAddLongPathPrefix(filePath); if (!PInvokeHelper.SetFileAttributes(filePath, attributes)) { // http://msdn.microsoft.com/en-us/library/ms681382(VS.85).aspx. var lastWin32Error = Marshal.GetLastWin32Error(); throw new Win32Exception( lastWin32Error, string.Format( Resources.ErrorSettingAttributes, lastWin32Error, filePath, attributes, CheckAddDotEnd(new Win32Exception(lastWin32Error).Message))); } }