?
Solved

Create Directory where Path exceeds MAX_PATH

Posted on 2013-01-30
16
Medium Priority
?
1,123 Views
Last Modified: 2013-02-04
I am using Delphi 2007 on Windows

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

ForceDirectories() does not work
0
Comment
Question by:Allan_Fernandes
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
16 Comments
 
LVL 19

Expert Comment

by:Thommy
ID: 38834627
It's an operatings system limit!!!
You cannot create paths exceeding MAX_PATH length...
Max Path Max File length Exception
0
 
LVL 19

Expert Comment

by:Thommy
ID: 38834635
0
 

Author Comment

by:Allan_Fernandes
ID: 38838286
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
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 

Author Comment

by:Allan_Fernandes
ID: 38840177
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
0
 
LVL 19

Expert Comment

by:Thommy
ID: 38840178
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...
0
 
LVL 46

Expert Comment

by:aikimark
ID: 38842300
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.
0
 

Author Comment

by:Allan_Fernandes
ID: 38842307
In combination with \\?\ and the Unicode versions of the Windows API
eg: CreateDirectoryW(PWideChar(WideString(ADir)), nil)
it is possible even in Delphi 2007.
0
 
LVL 25

Expert Comment

by:Coralon
ID: 38842327
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
0
 

Author Comment

by:Allan_Fernandes
ID: 38842514
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.
0
 
LVL 38

Expert Comment

by:Geert Gruwez
ID: 38842733
not all experts know everything
some of us even have a lucky break in pointing in the right direction
0
 
LVL 19

Expert Comment

by:Thommy
ID: 38842826
Sorry for my imperfect answer!

Agree with Geert, that no expert knows everything and any expert can learn some more...
0
 
LVL 43

Accepted Solution

by:
Davis McCarn earned 1500 total points
ID: 38843635
It is possible to exceed the 260 character path and filename limit; but, doing so has serious consequences in that CHKDSK will not be able to repair the drive and you will not be able to restore a backup created with most (99%) backup utilities.  The only workaround is to create a share to a parent folder so the limit is not reached using the share which solves the backup issue only.  In my humble opinion, creating a directory structure which cannot be repaired with CHKDSK is a setup for a major disaster.
P.S. I have over 36 years of, more than full time experience in servicing PC's of every type and 34 years of data recovery.  I have also personally encountered drives where nothing would recover those files which were more than 260 characters out.
0
 

Author Comment

by:Allan_Fernandes
ID: 38846089
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 ?
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question