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

Bug in Pri.LongPath.Path.GetDirectoryName when filename contains dot + whitespace #32

Closed
ngjermundshaug opened this issue Oct 27, 2015 · 3 comments

Comments

@ngjermundshaug
Copy link

There is a bug in Pri.LongPath.Path.GetDirectoryName when the filename contains '. ' (dot and then whitespace).

System.IO.Path.GetDirectoryName("C:\\myfolder\\Con. approval.pdf")    // ==> C:\myfolder (correct)
Pri.LongPath.Path.GetDirectoryName("C:\\myfolder\\Con. approval.pdf") // ==> \\. (not correct)

Seems to be a win32 bug:

NativeMethods.GetFullPathName("C:\\myfolder\\Con. approval.pdf", (uint)buffer.Capacity, buffer, IntPtr.Zero) ==> buffer is set to \\.\Con - which is not correct

I have reported this here: https://msdn.microsoft.com/en-us/library/windows/desktop/aa364963(v=vs.85).aspx

@peteraritchie
Copy link
Owner

If it's a windows bug, there may not be much that can be done.

@thomaslevesque
Copy link
Contributor

It's not because of the whitespace, it's because of the "con". "con" is a reserved filename (for the Console device), and a filename cannot include it as a whole word (of course something like "context" or "defcon" is fine). If you try to create a file named "Con. approval.pdf" or "con.pdf", it will fail.

@ngjermundshaug
Copy link
Author

Awesome! Thanks for clearing this up Thomas!

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

3 participants