Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why can't I check if a directory or a file? #18

Open
aloisdg opened this issue May 31, 2015 · 0 comments
Open

Why can't I check if a directory or a file? #18

aloisdg opened this issue May 31, 2015 · 0 comments

Comments

@aloisdg
Copy link
Owner

aloisdg commented May 31, 2015

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?

@aloisdg aloisdg changed the title Why cant I check if a directory or a file? Why can't I check if a directory or a file? May 31, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant