Avatar billede chw Nybegynder
16. juni 2005 - 16:28 Der er 4 kommentarer og
1 løsning

Lave sti på mere end 260 tegn

Hej.

Jeg gør således

Dim f As New FileInfo(strFinalPath)

        Dim sw As StreamWriter = f.CreateText()

Men får følgende fejl:

An unhandled exception of type 'System.IO.PathTooLongException' occurred in mscorlib.dll

Additional information: The path is too long after being fully qualified.  Make sure path is less than 260 characters.

Hvad skal man gøre for at oprette en sti på mere end 260 karakterer
Avatar billede arne_v Ekspert
16. juni 2005 - 17:39 #1
Hvad indeholder strFinalPath ?

Som jeg husker det kan total path godt overstige 255 men et enkelt path element
kan ikke.
Avatar billede chw Nybegynder
17. juni 2005 - 09:31 #2
den indeholder en sti som er over 255, men ingen enkelt mappe som er over 255. Du kan prøve at lave en path i din explorer, så kan du se den fejler.
Avatar billede arne_v Ekspert
17. juni 2005 - 18:34 #3
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/naming_a_file.asp

siger:

Maximum Path Length

In the Windows API, the maximum length for a path is MAX_PATH, which is defined as 260 characters. A path is structured in the following order: drive letter, colon, backslash, components separated by backslashes, and a null-terminating character, for example, the maximum path on the D drive is D:\<256 chars>NUL.

hvilket betyder at det bare ikke kan lade sig gøre punktum.
Avatar billede arne_v Ekspert
17. juni 2005 - 18:36 #4
det siger dog også:

The Unicode versions of several functions permit a maximum path length of approximately 32,000 characters composed of components up to 255 characters in length. To specify that kind of path, use the "\\?\" prefix.

    Note  The maximum path of 32,000 characters is approximate, because the "\\?\" prefix can be expanded to a longer string, and the expansion applies to the total length.

For example, "\\?\D:\<path>". To specify such a UNC path, use the "\\?\UNC\" prefix. For example, "\\?\UNC\<server>\<share>". These prefixes are not used as part of the path itself. They indicate that the path should be passed to the system with minimal modification. An implication of this is that you cannot use forward slashes to represent path separators, or a period to represent the current directory. You cannot use the "\\?\" prefix with a relative path. Relative paths are limited to MAX_PATH characters.

så du kan jo prøve at prefixe med "\\?\", men jeg vil nok frarråde den teknik
Avatar billede arne_v Ekspert
20. juni 2005 - 17:37 #5
OK ?
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester