Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Removing long paths

Reply
 
Old 10-22-2009   #1 (permalink)
Martin Zugec


 
 

Removing long paths

Heya,

I run into following problem - while trying to remove folder with long
name (stored on networks and needs to be accessed by FQDN), Remove-
Item reports following:
Remote-Item : The specified path, file name, or both are too long. The
fully qualified file name must be less than 260 characters, and the
directory name must be less than 248 characters.

Of course you can delete that folder from Explorer and even worse, you
can delete it from cmd

As a current workaround, I have to call Cmd /c RmDir /s /q
"$FolderPath"

I guess that limitation comes from API, but it's not very nice.

Any ideas? Or at least, could we get it in next Posh version (as far
as I remember, NTFS limitation is 32,000 characters)

Martin

My System SpecsSystem Spec
Old 10-22-2009   #2 (permalink)
Rob Campbell


 
 

RE: Removing long paths

Does it work if you creat a new psdrive at some point down the FQDN and do
your remove-item referenced from there?

"Martin Zugec" wrote:
Quote:

> Heya,
>
> I run into following problem - while trying to remove folder with long
> name (stored on networks and needs to be accessed by FQDN), Remove-
> Item reports following:
> Remote-Item : The specified path, file name, or both are too long. The
> fully qualified file name must be less than 260 characters, and the
> directory name must be less than 248 characters.
>
> Of course you can delete that folder from Explorer and even worse, you
> can delete it from cmd
>
> As a current workaround, I have to call Cmd /c RmDir /s /q
> "$FolderPath"
>
> I guess that limitation comes from API, but it's not very nice.
>
> Any ideas? Or at least, could we get it in next Posh version (as far
> as I remember, NTFS limitation is 32,000 characters)
>
> Martin
> .
>
My System SpecsSystem Spec
Old 10-22-2009   #3 (permalink)
Martin Zugec


 
 

Re: Removing long paths

Hi Rob,

yes, it works, but that's just workaround. Problem is that I run into
this in my framework and I don't know how it's going to be used, so I
need solution that will work everywhere\everytime

I am annoyed because these folders can be deleted from explorer\cmd,
but not from powershell

Martin
My System SpecsSystem Spec
Old 10-22-2009   #4 (permalink)
Larry__Weiss


 
 

Re: Removing long paths

http://www.codinghorror.com/blog/archives/000729.html

has a discussion of this limitation of the Windows API.

- Larry

Martin Zugec wrote:
Quote:

> Heya,
>
> I run into following problem - while trying to remove folder with long
> name (stored on networks and needs to be accessed by FQDN), Remove-
> Item reports following:
> Remote-Item : The specified path, file name, or both are too long. The
> fully qualified file name must be less than 260 characters, and the
> directory name must be less than 248 characters.
>
> Of course you can delete that folder from Explorer and even worse, you
> can delete it from cmd
>
> As a current workaround, I have to call Cmd /c RmDir /s /q
> "$FolderPath"
>
> I guess that limitation comes from API, but it's not very nice.
>
> Any ideas? Or at least, could we get it in next Posh version (as far
> as I remember, NTFS limitation is 32,000 characters)
>
My System SpecsSystem Spec
Old 10-29-2009   #5 (permalink)
Martin Zugec


 
 

Re: Removing long paths

Hi Larry,

yes, I know that link, however why is PowerShell using this older API
and limiting itself?

Martin
My System SpecsSystem Spec
Old 10-29-2009   #6 (permalink)


Ultimate 32
 
 

Re: Removing long paths

Martin,

Have you just simply tried shortening the paths?
My System SpecsSystem Spec
Old 10-29-2009   #7 (permalink)
Larry__Weiss


 
 

Re: Removing long paths

Comments by Microsoft at
https://connect.microsoft.com/PowerS...dbackID=276235
are interesting.

Posted by Microsoft on 1/13/2009 at 8:16 AM
None of PowerShell inherently has the path length limitations -- it all comes
from the .NET Framework. There is a working group around removing this
restriction, and we met with the CLR feature crew to discuss it as it relates to
PowerShell before the holiday break. They will be putting a wrapper class on
CodePlex in the near future for SOME support, with full support coming to the
real FileInfo and DirectoryInfo types in the next verison of the CLR.

- Larry


Martin Zugec wrote:
Quote:

> Hi Larry,
>
> yes, I know that link, however why is PowerShell using this older API
> and limiting itself?
>
> Martin
My System SpecsSystem Spec
Old 10-30-2009   #8 (permalink)
Martin Zugec


 
 

Re: Removing long paths

@Lancelot: that would be easiest solution, however is not possible :
( My solution is exporting parts of SCCM - configuration is exported
to XML files and sources are exported also. I run into this limitation
when handling with applications like XenApp or some Adobe products,
that likes to store some files in locations like "Bin\Program Files
\Adobe\Acrobat Reader..."

@Larry: Interesting - I hope it will be available as soon as possible,
because this is pretty dangerous situation (especially when cmd and
explorer supports longer paths)
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Cannot delete filenames/paths too long!! Vista file management
Long paths VB Script
File Paths Too Long Vista file management
Looking for function to resolve VirtualStore paths to physical paths Vista file management
Looking for function to resolve VirtualStore paths to physical paths Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46