aloisdg / aloisdg/Doccou

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

Aperta
#18 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
help wanted question
Lingua principale
C#
Stelle
19
Fork
448
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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](https://github.com/aloisdg/CountPages/commit/cfce111383cedd5709c0237a976fd45e8fd3aacd#diff-1d71ae4b623a65206a7c1eb568252fc1R89).

Any idea?

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.