Calling File.Delete() on a directory yields a misleading irrelevant exception - by Dmitry Me

Status : 

  Won't Fix<br /><br />
		Due to several factors the product team decided to focus its efforts on other items.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 774001 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 12/11/2012 1:38:42 AM
Access Restriction Public


If I call System.IO.File.Delete() and pass it a directory path instead of file path I get UnathorizedAccessException with text "Access to the path <path> is denied.". This is seriously misleading because it implies I have some problems with permissions while the real problem is that the path identifies a directory and not a file.

It should be something like an InvalidOperationException and the text should be something like "Path <path> is a directory, file path required."

Sign in to post a comment.
Posted by Microsoft on 12/11/2012 at 10:12 PM
Thank you for submitting feedback on Visual Studio and .NET Framework. Your issue has been routed to the appropriate VS development team for investigation. We will contact you if we require any additional information.
Posted by Macy [MSFT] on 12/11/2012 at 1:50 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(