Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2013-11

Deleteing a file that has a path that's longer than 256 characters

8 messages · 4 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Richard Mace

Hi All,
I have an issue where I am unable to delete a file where the path name is longer than 256 characters.
Interesting enough, the error as reported from Windows (SysErrorMessage(GetLastError)) reports that Windows is unable to find the path specified.
I have even tried renaming the file so that it is shorter (within the full path) but I am unable to do that as Windows complains of the same error message.
It lookis like it is a temeporay internet file that explorer has created (if that helps)

Any ideas?

Lazarus 1.2 RC1 Windows Server 2003

Richard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20131126/ddb6b7bd/attachment.html>

Reply by email

Frederic Da Vitoria
to Richard Mace

2013/11/26 Richard Mace

Show quoted text 17 lines
Hi All, I have an issue where I am unable to delete a file where the path name is longer than 256 characters. Interesting enough, the error as reported from Windows (SysErrorMessage(GetLastError)) reports that Windows is unable to find the path specified. I have even tried renaming the file so that it is shorter (within the full path) but I am unable to do that as Windows complains of the same error message. It lookis like it is a temeporay internet file that explorer has created (if that helps) Any ideas? Lazarus 1.2 RC1 Windows Server 2003

This is a pretty frequent Windows issue. IIRC, you have several options: 1: try to delete the file in a DOS shell using short names (for example replacing "My Documents" with "mydocu~1"). This is the best option as it avoids changing anything in your system. But it may not work because even the shortened path may be too long.
2+: see all the options form http://support.microsoft.com/kb/320081 , but I'd use solution 3 before solution 2 if the directory where your file is stored is installed by some software (as is suggested by your mention of "temporary internet file". If you have to use solution 2, then be careful to restore the original directory names before running any software which might use this directory.

Frederic Da Vitoria (davitof) Membre de l'April - ? promouvoir et d?fendre le logiciel libre ? - http://www.april.org -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20131126/8c6e22ff/attachment.html>

Reply by email

Craig Peterson
to Richard Mace: I have an issue where I am unable to delete a file where the path name is longer than 256…
Richard Mace wrote
I have an issue where I am unable to delete a file where the path name is longer than 256 characters.

You need to call the Unicode variant of the file APIs and add \\?\ to the start of the path in order to interact with paths longer than MAX_PATH. See http://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx#maxpath for details.

Craig Peterson Scooter Software -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20131126/2be4a960/attachment.html>

Reply by email

Frederic Da Vitoria
to Craig Peterson

2013/11/26 Craig Peterson

Show quoted text 12 lines
On Nov 26, 2013, at 7:59 AM, Richard Mace wrote: I have an issue where I am unable to delete a file where the path name is longer than 256 characters. You need to call the Unicode variant of the file APIs and add \\?\ to the start of the path in order to interact with paths longer than MAX_PATH. See http://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx#maxpathfor details.

Richard wanted to delete his file programmatically, of course, else he wouldn't be asking his question in this list :-P

Frederic Da Vitoria (davitof) Membre de l'April - ? promouvoir et d?fendre le logiciel libre ? - http://www.april.org -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20131126/10682cd9/attachment-0001.html>

Reply by email

Reinier Olislagers
to Frederic Da Vitoria
Frederic Da Vitoria wrote 13 lines
2013/11/26 Craig Peterson < <mailto:>> On Nov 26, 2013, at 7:59 AM, Richard Mace < <mailto:>> wrote: > I have an issue where I am unable to delete a file where the path > name is longer than 256 characters. You need to call the Unicode variant of the file APIs and add \\?\ to the start of the path in order to interact with paths longer than MAX_PATH. See http://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx#maxpath for details. Richard wanted to delete his file programmatically, of course, else he wouldn't be asking his question in this list :-P

I think Craig understands that - how do you intend to call APIs from the command line? (Yes, rundll probably but ok).
Otherwise, could you explain a bit more?

BTW: IIRC, there was a huge discussion about using the unicode API for (once again IIRC) exactly the file deletion/manipulation API calls in the FPC list. @Richard: you could have a search through there...

Reply by email

Frederic Da Vitoria
to Reinier Olislagers

2013/11/26 Reinier Olislagers

Show quoted text 24 lines
On 26/11/2013 15:43, Frederic Da Vitoria wrote: > 2013/11/26 Craig Peterson < > <mailto:>> > On Nov 26, 2013, at 7:59 AM, Richard Mace < > <mailto:>> wrote: >> I have an issue where I am unable to delete a file where the path >> name is longer than 256 characters. > You need to call the Unicode variant of the file APIs and add \\?\ > to the start of the path in order to interact with paths longer than > MAX_PATH. > See http://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx#maxpath > for details. > Richard wanted to delete his file programmatically, of course, else he > wouldn't be asking his question in this list :-P I think Craig understands that - how do you intend to call APIs from the command line? (Yes, rundll probably but ok). Otherwise, could you explain a bit more? BTW: IIRC, there was a huge discussion about using the unicode API for (once again IIRC) exactly the file deletion/manipulation API calls in the FPC list. @Richard: you could have a search through there...

Obviously Craing understood, and I did not. I was laughing at myself :-)

Frederic Da Vitoria (davitof) Membre de l'April - ? promouvoir et d?fendre le logiciel libre ? - http://www.april.org -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20131126/23964a3c/attachment.html>

Reply by email

Reinier Olislagers
to Frederic Da Vitoria
Frederic Da Vitoria wrote 15 lines
2013/11/26 Reinier Olislagers < <mailto:>> > Richard wanted to delete his file programmatically, of course, else he > wouldn't be asking his question in this list :-P I think Craig understands that - how do you intend to call APIs from the command line? (Yes, rundll probably but ok). Otherwise, could you explain a bit more? BTW: IIRC, there was a huge discussion about using the unicode API for (once again IIRC) exactly the file deletion/manipulation API calls in the FPC list. @Richard: you could have a search through there... Obviously Craing understood, and I did not. I was laughing at myself :-)

Laughter is always good ;)
Sorry, got a bit mixed up because you posted that below his reply instead of yours ;)

Reply by email

Richard Mace
to Frederic Da Vitoria: 2013/11/26 Richard Mace This is a pretty frequent Windows issue. IIRC, you have several…

Many thanks for this input Frederic, I'll check it out.

Richard

Frederic Da Vitoria wrote 46 lines
2013/11/26 Richard Mace > > Hi All, > I have an issue where I am unable to delete a file where the path name is > longer than 256 characters. > Interesting enough, the error as reported from Windows > (SysErrorMessage(GetLastError)) reports that Windows is unable to find the > path specified. > I have even tried renaming the file so that it is shorter (within the > full path) but I am unable to do that as Windows complains of the same > error message. > It lookis like it is a temeporay internet file that explorer has created > (if that helps) > > Any ideas? > > Lazarus 1.2 RC1 Windows Server 2003 > This is a pretty frequent Windows issue. IIRC, you have several options: 1: try to delete the file in a DOS shell using short names (for example replacing "My Documents" with "mydocu~1"). This is the best option as it avoids changing anything in your system. But it may not work because even the shortened path may be too long. 2+: see all the options form http://support.microsoft.com/kb/320081 , but I'd use solution 3 before solution 2 if the directory where your file is stored is installed by some software (as is suggested by your mention of "temporary internet file". If you have to use solution 2, then be careful to restore the original directory names before running any software which might use this directory. -- Frederic Da Vitoria (davitof) Membre de l'April - ? promouvoir et d?fendre le logiciel libre ? - http://www.april.org -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20131126/8315cc77/attachment.html>

Reply by email