简体   繁体   中英

The file resolves to a path that is too long. The maximum length is 260 characters

I am running a C# .NET WPF application on a Fujitsu tablet running Windows 7, accessing a SQL Server CE 3.5 database installed in the user's AppData folder. This application works correctly on other tablets of the same type and also on normal laptops or desktop PCs.

When the application runs on one particular tablet, I get the error:

The file resolves to a path that is too long. The maximum length is 260 characters 
[File name = c:\Users\tester\AppData\Roaming\Fourmative\AppDatabase\MyDatabase#1.sdf]

Now, I have read up about the limitations on windows path names and the maximum length being 260 characters. However, as you can see, the length of this path is only 72 characters.

Also, as the Application is installed in the user's AppData folder as part of the installer, I cannot really control, on any one user machine, where this path will point to exactly.

I assume that this must mean that the ACTUAL path is actually mapped somehow from the path shown? So, my question is, how can I find the full actual path (the one that must be 260 characters) from the command line so that I can determine how to really fix this issue.

Windows path is unlimited, but one needs to use different syntax.

from http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx :

The Windows API has many functions that also have Unicode versions to permit an extended-length path for a maximum total path length of 32,767 characters. This type of path is composed of components separated by backslashes, each up to the value returned in the lpMaximumComponentLength parameter of the GetVolumeInformation function (this value is commonly 255 characters). To specify an extended-length path, use the "\\?\\" prefix. For example, "\\?\\D:\\very long path".

I'm not sure that "MyDatabase#1.sdf" is a valid file name. I doubt that # is a valid character, it might be the cause of the problem, somehow...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM