Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

What version of MS Operating Systems support the long file path feature \\?\

Avatar of malcolm29
malcolm29Flag for United States of America asked on
Operating SystemsWindows OSWindows 10
3 Comments1 Solution132 ViewsLast Modified:
I am trying to read in file names that have paths longer than 266 characters.  So, I'm using \\?\ as a pre-pend to the file name.

This works great on my Windows 10 machine, but when I try to run it (using PowerShell v. 4) on a Windows Server 2012 R2 Datacenter machine (Windows version 6.3.9600), I get error messages leading me to assume that the feature is not supported.

Here's my actual PowerShell code to test this.  Again, this works fine on my Win10 desktop, but not the server:
$sFileName = "\\?\H:\COMMUNITY\Compliance\AQIP\2010 Systems Portfolio\Systems Portfolio Draft orig (Autosaved).docx"
$objFileStream = New-Object IO.FileStream($sFileName,[System.IO.FileMode]::Open)

The error I get is:
New-Object : Exception calling ".ctor" with "2" argument(s): "Illegal characters in path."
At H:\Information Technology\InstallFilesOld\OtherPSScripts\Test.ps1:2 char:18
+ $objFileStream = New-Object IO.FileStream("\\?\$($sFileName)",[System.IO.FileMod ...
+                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [New-Object], MethodInvocationException
    + FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand

If I run the code without the \\?\ (using the following code), I don't get any errors.
$sFileName = "H:\COMMUNITY\Compliance\AQIP\2010 Systems Portfolio\Systems Portfolio Draft orig (Autosaved).docx"
$objFileStream = New-Object IO.FileStream($sFileName,[System.IO.FileMode]::Open)
Avatar of Jeremy Weisinger
Jeremy WeisingerSenior Network Consultant / Engineer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answers