Long path names in win32 process of a Desktop Bridge app

Jos Huybrighs 336 Reputation points
2020-01-09T21:14:50.827+00:00

I have a problem accessing long path names in the win32 process of my Desktop Bridge app.
I added every suggestion I could find about this but when I call DirectoryInfo in the win32 process on a folder that has a long pathname, the attributes of the directory are always set to -1.
The directory info is obtained as follows:

DirectoryInfo dir = new DirectoryInfo(dirPath);
  1. The win32 process is build against .net Framework 4.7.2
  2. The registry has of course the correct setting for long pathnames.
  3. I also tried all the suggestions about the manifest file and adding a WindowsSettings tag and longPathAware tag but with no luck: - It can't be added in the 'packaging' project (different schemas concept). - It can be added in the win32 manifest but same error and I also don't think that a win32 manifest is actually used in a Desktop Bridge app. - And last, I'm not sure whether the manifest entry is still required when building against 4.7.2.

My test involves a local directory within which I created a couple of subfolders to get to something bigger than 260. I copied also some files in those folders. All done using Powershell.

Any idea what to do here?

Universal Windows Platform (UWP)
{count} votes

Accepted answer
  1. Jos Huybrighs 336 Reputation points
    2020-01-10T14:45:14.563+00:00

    I managed to get it working by changing all my pathnames to the 'DOS Device Path' format, This is:

        C:\Temp becomes \\?\C:\Temp, and  
        \\Mars\Share\Temp becomes \\?\UNC\Mars\Share\Temp  
    

    See Path Format Overview

    That is not what I would expect to do in 2020 when using .Net Framework 4.7 and higher. It is unclear whether something still has to be set in the manifest file (I don't think it is). And, if it is really necessary, it is even more unclear how to do that in a Desktop Bridge app.
    The DOS Device Path format however seems to do the trick.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anton Clark 1 Reputation point
    2020-04-02T05:14:48.62+00:00

    Long path tool was always there for me in this type of

    problem. I've been using it for months now and it is

    really helpful