I need to know if I can create a file in a specific folder, but there are too many things to check such as permissions, duplicate files, etc. I’m looking for something like File.CanCreate(@'C:\myfolder\myfile.aaa'), but haven’t found such a method. The only thing I thought is to try to create a dummy file and check for exceptions but this is an ungly solution that also affects performance. Do you know a better solution?
I need to know if I can create a file in a specific folder,
Share
In reality, creating a dummy file isn’t going to have a huge performance impact in most applications. Of course, if you have advanced permissions with create but not destroy it might get a bit hairy…
Guids are always handy for random names (to avoid conflicts) – something like: