Les Snippets

Connexion

Récupérer un chemin de fichier au format Short (même si ce fichier n'existe pas)

Niveau requis pour utiliser/comprendre cette source : 1 ( Débutant )
Créé le 28/08/2007 21:18:10 et initié par PCPT [Liste]
Date de mise à jour : 24/10/2007 23:24:55
Vue : 4072
Catégorie(s) : API, Chaîne de caractères
Langage sélectionné : VB.NET 1.x
Langages dispo pour ce code :
- VB6, VBA
- VB 2005, VB.NET 1.x
- C# 1.x, C# 2.x
- Voir tous les langages pour ce code snippet



Langage : VB.NET 1.x , VB 2005
Date ajout : 24/10/2007
Posté par Charles Racaud [Liste]

Shared Function GetShortPathName_CreateDestroy(ByVal Path As StringAs String
  Dim fCreate As Boolean = Not System.IO.File.Exists(Path)
  If fCreate Then System.IO.File.Create(Path).Dispose()
  Dim shortPath As String = GetShortPathName(Path)
  If fCreate Then System.IO.File.Delete(Path)
  Return shortPath
End Function
Shared Function GetShortPathName(ByVal Path As StringAs String
  Dim shortPath As New System.Text.StringBuilder(255)
  GetShortPathName(Path, shortPath, shortPath.Capacity)
  Return shortPath.ToString()
End Function
<System.Runtime.InteropServices.DllImport("kernel32.dll", SetLastError:=True, _
  CharSet:=System.Runtime.InteropServices.CharSet.Auto)> _
Private Shared Function GetShortPathName(ByVal Path As String, _
  ByVal ShortPath As System.Text.StringBuilder, _
  ByVal ShortPathLength As IntegerAs Integer
End Function

Remarque :
La fonction GetShortPathName_CreateDestroy fait une vérification si le fichier existe, si non, le fichier est crée pour récupéré son chemin court puis est supprimé.
Tandis que la fonction GetShortPathName ne teste pas son existence. (Renvois "" si il n'existe pas)

Snippets en rapport avec : Fichier, Chemin, Récupérer, Short, Court



Codes sources en rapport avec : Fichier, Chemin, Récupérer, Short, Court

{Visual Basic, VB6, VB.NET, VB 2005} GETNAMES : RÉCUPÈRE ET ÉCRIT TOUS LES NOMS DE FICHIERS D'UN DOSSIER
J'ai fait ce petit programme tout simple, qui aurait pu être créé par n'importe quel débutant, car j...

{Visual Basic, VB6, VB.NET, VB 2005} NTFS RECOVER : RÉCUPÉRER LES FICHIERS EFFACÉS D'UNE PARTITION NTFS
Ce code permet de récupérer les fichiers effacés de vos partitions NTFS. Pour cela, vous devez avoir...

{Visual Basic, VB6, VB.NET, VB 2005} ALGORITHME DE PATHFINDING ASTAR
Cet algorithme célèbre est un algorithme de type PathFinding. Il recherche le chemin le plus rap...

{Delphi} ASTAR - A* RECHERCHE DU PLUS COURT CHEMIN
bonjour, je poste la source d'un A* codé l'an passé. C'était mon premier programme donc je me suis...

{Javascript / DHTML} RECHERCHE DU PLUS COURT CHEMIN - ALGO DE DIJKSTRA - EN JAVASCRIPT
L'algorithme de Dijkstra est aussi appelé algorithme de recherche du plus court chemin, il permet do...

{Visual Basic, VB6, VB.NET, VB 2005} CHERCHE LE CHEMIN LE PLUS COURT !
application de l'algorithme GREEDY (cherche un chemin pour arriver au sommet désiré)...

{C / C++ / C++.NET} DECOUPAGE CHEMIN FICHIER (FORUM)
Suite a une demande sur le forum, voila un code qui permet de découper le chemin d'un fichier en so...

{Foxpro} COMMENT ANALYSER LE CHEMIN D'UN FICHIER AVEC WINDOWS SCRIPTING HOST
Le code requiert l'installation de Windows Scripting Host Plateformes supportées: Windows Server...

{ColdFusion} RÉCUPÈRER LE CHEMIN D'UN FICHIER SUR LE SERVEUR DISTANT
L'utilisation de la balise CFFILE nécessite de connaître le chemin absolu pour uploader les fichi...

{Visual Basic, VB6, VB.NET, VB 2005} DRAG & DROP D'UN FICHIER ET EXTRACTION DU NOM ET DU CHEMIN
Ce code reprend une partie de l'exemple de Drag & Drop de la source de goth (voir le lien http://www...