If I use System.IO.File.Open with FileMode.CreateNew, and the file
already exists I get an IOException. Ok... but there is no specific
exception for "file already exists", so how do I determine
programatically that that was indeed the cause?

Re: FileMode.CreateNew when file already exists by doug

doug
Fri Jan 05 01:00:35 CST 2007

doug mansell wrote:
> If I use System.IO.File.Open with FileMode.CreateNew, and the file
> already exists I get an IOException. Ok... but there is no specific
> exception for "file already exists", so how do I determine
> programatically that that was indeed the cause?
>

oh silly me...

System.Runtime.InteropServices.Marshal.GetHRForException