Doccou
Doccou copied to clipboard
Why can't I check if a directory or a file?
Hello,
During the developement of the feature which allow to drag and drop a directory (see #15), I faced a behavior that I couldnt understand.
I wrote two snippets who check if a path is a directory or a file. Any of them worked the way I think they would work.
First one:
if (!Directory.Exists(path))
{
}
Second one:
if (!File.GetAttributes(path).HasFlag(FileAttributes.Directory))
{
}
Finally I fixed it with a hack-feel solution, I checked if the path contains a extension or not. This hack will not work with a file without an extension. I can't keep that.
You can see the problem here.
Any idea?