Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
2888 connectés 

 


Dernière réponse
Sujet : [VB] Transformer un pathname windows en pathname DOS (noms courts) ?
nix_ Merci!  
J'essaye ca demain! ;)

Votre réponse
Nom d'utilisateur    Pour poster, vous devez être inscrit sur ce forum .... si ce n'est pas le cas, cliquez ici !
Le ton de votre message                        
                       
Votre réponse


[b][i][u][strike][spoiler][fixed][cpp][url][email][img][*]   
 
   [quote]
 

Options

 
Vous avez perdu votre mot de passe ?


Vue Rapide de la discussion
nix_ Merci!  
J'essaye ca demain! ;)
HelloWorld Il me semble qu'il y a une API pour ca ...
ha ca y est, j'ai trouvé : GetShortFileName ...
 
voila : (dans un module) :
 
Private Declare Function GetShortPathName Lib "kernel32" _
   Alias "GetShortPathNameA" (ByVal lpszLongPath As String, _
   ByVal lpszShortPath As String, ByVal cchBuffer As Long) _
   As Long
 
Public Function GetShortFileName(ByVal FullPath As String) _
  As String
 
'PURPOSE: Returns DOS File Name (8.3 Format) Give
'FullPath for long file name
 
'PARAMETERS: FullPath: Full Path of Original File
 
'RETURNS: 8.3 FileName, or "" if FullPath doesn't
'         exist or file fails for other reasons
 
'EXAMPLE:  
'Debug.Print _
'  GetShortFileName("C:\My Documents\My Very Long File Name.doc" )
 
'If file exists, will display C:\MYDOCU~1\MYVERY~1.DOC
'in the debug window
 
Dim lAns As Long
Dim sAns As String
Dim iLen As Integer
   
On Error Resume Next
 
'this function doesn't work if the file doesn't exist
If Dir(FullPath) = "" Then Exit Function
 
sAns = Space(255)
lAns = GetShortPathName(FullPath, sAns, 255)
GetShortFileName = Left(sAns, lAns)
     
End Function
 
 
et donc NomCourt = GetShortFileName(NomLong)
nix_ Comment transformer un pathname windows ( avec noms longs ) en pathname DOS (noms courts) avec les ~1 ?
Merci! ;)

Copyright © 1997-2025 Groupe LDLC (Signaler un contenu illicite / Données personnelles)