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

Directory.Exist return strange result #12

Closed
Fabsky opened this issue Oct 14, 2014 · 4 comments
Closed

Directory.Exist return strange result #12

Fabsky opened this issue Oct 14, 2014 · 4 comments
Assignees

Comments

@Fabsky
Copy link
Contributor

Fabsky commented Oct 14, 2014

I'm trying your library.
The application is a bit special: it's a namespace extension.
At some place, I've this method:

public string CreateFolder(string mirror)
        {
            var local = Path.Combine(this._rootFolder, handleInvalidCharacters(mirror));
            if (!Directory.Exists(local))
                Directory.CreateDirectory(local);
            return local;
        }

This method is called maybe 10x in parallel by windows.
The Directory.Exists return true ... but the folder doesn't exists. It's never created.

In VS if I type these commands::

Pri.LongPath.Directory.Exists(local)
true
System.IO.Directory.Exists(local)
false

If I try in a "safe" environment with one simple execution, the method correctly return false

Any idea ?
Thank you

@Fabsky
Copy link
Contributor Author

Fabsky commented Oct 15, 2014

Here is a screenshot when debugging the source code (Common.cs line 70)
The path doesn't exists (the drop folder exists, but not the "Clients _ Quatre" folder)
I think the problem comes from the fact that Directory.IsDirectory(-1) return true ?

image

This is the same path, but executed from nunit test:

image

The problem comes from Marshal.GetLastWin32Error(); which return 0 (Common.cs line 114)
In a unit test, it returns 2. But in the namespace extension application, it returns 0

@Fabsky
Copy link
Contributor Author

Fabsky commented Oct 15, 2014

See #13

peteraritchie added a commit that referenced this issue Nov 8, 2014
Fixes issue #12: Directory.Exist return strange result
@peteraritchie
Copy link
Owner

Still trying to repo, if you could create a unit test gist (or just paste code in the issue) that repros it, that would help me get to it sooner :)

@peteraritchie peteraritchie self-assigned this Dec 5, 2014
@peteraritchie
Copy link
Owner

I assume the PR from #13 fixes this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants