Skip to main content

PowerShell File Path Too Long

Striving hard to work on files and folders whose paths are too long in PowerShell?

Well, it’s not hard anymore it can easily be done on PowerShell.

With the master piece of Johan Delimon, the Delimon.Win32.I​O Library (V4.0) is of very great help.

The file can be downloaded on TechNet gallery on this link below:

Download the file and install it.

And with this piece of snippet code, accessing long path exceeding 260 characters or more is not a problem.

This code snippet below will read the files on a path which exceeds the path limitation.


#Load the  DLL to PowerShell
[Reflection.Assembly]::LoadFile("C:\Program Files\Delimon\Delimon.Win32.IO\Delimon.Win32.IO.dll")

#Access the method or the function of the DLL to read the files
#Note: Line below has to be in one line

 $xstr = $xstr =[Delimon.Win32.IO.Directory]::GetFiles("\\servername\very very long path exceeding 256 or 260 chars")
 ForEach ($oFile In $xstr) {
      #Display to the console the files on the long path of folders
    write-host $oFile           


That’s it guys! With the help of the Delimon DLL, path limitation is not a limitation anymore.

Appreciate if you can share your piece of code as well, on how you are able to implement it.

Robocopy can also list files and folders for path that are too long.

See link below:

Copy files with specific extension, script is able to copy even path exceeds the 256 limit:

Sharing and generosity in all kind of ways, makes life easier.

Till next time!! Happy coding!! Cheers!!!!

Linux Android App cheat sheet:

Download Prayer App "Heaven's Dew Fall" from Google Play store or click below:

Android Divine Mercy Chaplet Guide 

Heaven's Dew Fall Google Play Link:

Rosary Guide for Android Phone:


  1. Hi there, this is what I'm looking for however I cant get it to work. I'm looking to do a recursive get files on a user profile folders to get the count of files and size. However a large number of file paths are over the 260 character length. When I use the above code, I just get "arithmetic operation resulted in an overflow". Can you give a powershell example showing a recursive search for a unc path?

    $xstr = $xstr =[Delimon.Win32.IO.Directory]::GetFiles("\\server\profiles$\username.V2")
    Exception calling "GetFiles" with "1" argument(s): "Arithmetic operation resulted in an overflow."

  2. Hi, the source code for the DLL is not open source. I guess you might have run into a bug or the limitation of the DLL itself. The author of the DLL don't have any updates for this issue. or check out this link:

  3. Hello
    You can also use Long Path Tool to sort out this problem.


  4. Hi,

    PowerShell can easily be used with AlphaFS.dll to do actual file I/O stuff

    without the PATH TOO LONG hassle.

    Please see at Codeplex: [This link is external to TechNet Wiki. It will open in a new window.] for this .NET project.

  5. “Long Path Tool” program is the best solution for your problem


Post a Comment

Popular posts from this blog

Copy a single file using robocopy

Copy a single file using robocopy from a local folder to a shared folder on the network.
A simple rule of thumb before any disaster strike, don't interchange the source and the destination.

If source and destination is mistakenly reverse, files might get overwritten. To avoid any loss of data do a test with a dummy file to ensure things work perfectly.
Robocopy [source][destination]   [file to be copied]
robocopy c:\local_c_folder  \\PC_network\shared_folder   file_to_be_copied_xx.txt
The command will be completed successfully provided the network access right has no issues.

Robocopy works quite good on large files. A simple copy or xcopy command will also work but the speed might vary.

Robocopy is free it can be accessed from command line. No need to install the resource kit tool if the operating system is Windows 7 or newer version.

Copy files with selected file extension using PowerShell and Robocopy:

$extension = ('.pdf', '.jpg', '.txt')
gci d:\WorkFolde…

WMIC get computer name

WMIC get computer model, manufacturer, computer name and  username.
WMIC is a command-line tool and that can generate information about computer model, its manufacturer, its username and other informations depending on the parameters provided.
Why would you need a command line tool if there’s a GUI to check?
If you have 20 or 100 computers, or even more. It’s quite a big task just checking the GUI to check the computer model and username.
If you have remote computers, you need to delegate someone in the remote office or location to check.
Or you can just write a batch file or script to automate the task.
Here’s the code below on how get computer model, manufacturer and the username.
Open an elevated command prompt and type:
wmic computersystem get "Model","Manufacturer", "Name", "UserName"
Just copy and paste the code above, the word “computersystem” does not need to be change to a computer name.
A sample output below will be generated if the co…