I have the following C# code that creates a folder:
if (!Directory.Exists(strCreatePath))
{
Directory.CreateDirectory(strCreatePath);
}
It works, except if I have a folder as such: C:\\Users\\UserName\\Desktop the Directory.Exists returns false, which is not true, but then Directory.CreateDirectory throws an exception: Access to the path 'C:\\Users\\UserName\\Desktop' is denied..
Any idea how to prevent that apart from catching such exception, which I prefer to avoid?