Link to home
Start Free TrialLog in
Avatar of Allan_Fernandes
Allan_Fernandes

asked on

Create Directory where Path exceeds MAX_PATH

I am using Delphi 2007 on Windows

Could you advice how to create folder where path already exceeds MAX_PATH.

ForceDirectories() does not work
Avatar of Thommy
Thommy
Flag of Germany image

It's an operatings system limit!!!
You cannot create paths exceeding MAX_PATH length...
Max Path Max File length Exception
Avatar of Allan_Fernandes
Allan_Fernandes

ASKER

I am very disappointed with the solutions experts exchange has been providing.
Anyways I have already found the solution.

ps: I cannot tell my customer about above mentioned limitations wherein I am the software professional and he is just a computer user. Today everyone has folders above Max_Path due to unicode
I've requested that this question be closed as follows:

Accepted answer: 0 points for Allan_Fernandes's comment #a38838286

for the following reason:

As Mentioned above
The only correct answer to the question is, that it is not possible to create longer paths under windows!!!

Cannot understand why the asker is disappointed about that truth.

I'm very interested in Allan_Fernandes solution.
He should post his solution, otherwise I would have deserved the points...
Avatar of aikimark
The Max_Path applies to API calls when creating directories, renaming files, etc.  In the referenced link, unicode (WCHAR) strings might bump that to ~32k, which is some new knowledge for me.

Since the VCL generally wraps API calls, I would expect that the Max_Path encountered by  Allan_Fernandes is the ~260 character limit.  If he has found a work-around, it is likely to be with some library that bypasses the API limitation.  My guess would be the FileSystemObject library provided by the Scripting Runtime DLL.
In combination with \\?\ and the Unicode versions of the Windows API
eg: CreateDirectoryW(PWideChar(WideString(ADir)), nil)
it is possible even in Delphi 2007.
Was going to jump on this, but you already figured the answer out Allan :-)  Using the UNC path, you can bypass the shell restrictions on MAX_PATH and directly access the file system by API.  

I actually had a file named com2.lnk I couldn't delete by any 'standard' method, and I was able to delete it in cmd.exe using \\?\f:\<path>\com2.lnk.

Coralon
From what Coralon has said and my solution it is clear that the statement of 'EE Admin' is making is improper.

It is sad that to see that you are not taking our questions seriously. Please advice.
not all experts know everything
some of us even have a lucky break in pointing in the right direction
Sorry for my imperfect answer!

Agree with Geert, that no expert knows everything and any expert can learn some more...
ASKER CERTIFIED SOLUTION
Avatar of Davis McCarn
Davis McCarn
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Firstly let me clear the fact the I do not intend to hurt anyone's feelings or snatch anyone's points. I too am in this field from 25 yrs and my main product is a Desktop Backup/Restore software. Several of my clients have long folders names and I end up losing the orders if I cannot handle that.
All I am asking for is that I need to fall back on experts like you when faced with situations I cannot handle. I have been paying your charges for a long time and yet you will notice me asking questions only after having done my study seriously. I am also aware that you have a strong team and are in the capacity of helping me.
My need is to know how to reach the correct experts ?