Les Snippets

Connexion

Recuperer le nom "long" d'un fichier à partir d'un "court"

Niveau requis pour utiliser/comprendre cette source : 1 ( Débutant )
Créé le 03/10/2008 20:58:22 et initié par Charles Racaud [Liste]
Vue : 1253
Catégorie(s) : Fichier / Disque
Langages dispo pour ce code :
- VB6, VBA
- C# 1.x, C# 2.x, C# 3.x
- VB 2005, VB 2008



Langage : VB6 , VBA
Date ajout : 03/10/2008
Posté par Charles Racaud [Liste]
Private Const MAX_PATH = 260
Private Declare Function GetLongPathNameW Lib "kernel32" ( _
  ByVal lpszShortPath As LongByVal lpszLongPath As Any, _
  ByVal cchBuffer As LongAs Long
Public Function GetLongPathName(lpszShortPath As StringAs String
  Dim LongFileName As String * MAX_PATH
  Dim LongFileNameLen As Long
  LongFileNameLen = GetLongPathNameW(StrPtr(lpszShortPath), LongFileName, MAX_PATH)
  GetLongPathName = VBA.Left$(StrConv(LongFileName, vbFromUnicode), LongFileNameLen)
End Function

Langage : C# 1.x , C# 2.x , C# 3.x
Date ajout : 05/10/2008
Posté par MorpionMx [Liste]
private const int MAX_PATH = 255;
[DllImport("kernel32.dll", SetLastError=true, CharSet=CharSet.Auto)]
static extern uint GetLongPathName( string lpszShortPath, [Out] StringBuilder lpszLongPath, uint cchBuffer);

public static string GetLongPathName(string lpszShortPath)
{
    StringBuilder sb = new StringBuilder(MAX_PATH);
    GetLongPathName(lpszShortPath, sb, MAX_PATH);
    return sb.ToString();
}
Langage : VB 2005 , VB 2008
Date ajout : 15/10/2008
Posté par Willi [Liste]
Private Const MAX_PATH As Integer = 255
<DllImport("kernel32.dll", SetLastError := True, CharSet := CharSet.Auto)> _
Private Function GetLongPathName(ByVal lpszShortPath As String,   <Out()> _
ByVal lpszLongPath As System.Text.StringBuilder, ByVal cchBuffer As UInteger) As UInteger
End Function
Public Shared Function GetLongPathName(ByVal lpszShortPath As String) As String
  Dim sb As New System.Text.StringBuilder(MAX_PATH)
  GetLongPathName(lpszShortPath, sb, MAX_PATH)
  Return sb.ToString()
End Function
Remarque :
Ajouter la directive
Imports System.Runtime.InteropServices

Snippets en rapport avec : File, Fichier, Nom long



Codes sources en rapport avec : File, Fichier, Nom long

{} NOM FICHIER
Validation du nom d'un fichier. - Accepte : File.txt | C:\Data\..\.\CodeSSourceS.Regex\MonFichier...

{Visual Basic, VB6, VB.NET, VB 2005} FAT RECOVER : RÉCUPÉRER LES FICHIERS EFFACÉS DE VOS PARTITIONS FAT (CARTE MÉMOIRE ET CO)
Ce code permet de récupérer les fichiers effacés sur les partitions FAT12, FAT16 et FAT32. Pour cela...

{PHP} CLASSE DIRECTORYITERATOR POUR PHP4
Dans le cadre d'un de mes projets, j'utilise la classe PHP 5 DirectoryIterator vraiment utile pour l...

{Visual Basic, VB6, VB.NET, VB 2005} ENREGISTRER ET CHARGER LISTVIEW DANS FICHIER AVEC IMAGE ETC...
Salut a tous, Voici un ptit code pour enregistrer une listview dans un fichier et la recharger de...

{JAVA / J2EE} CLASS FILE UTILITIES / CLASSE UTILITAIRE DE MANIPULATION DE FICHIERS
Petite classe toute bête de manipulation de fichiers, simple mais tellement utile ;) voila, si ça p...

{Visual Basic, VB6, VB.NET, VB 2005} MODIFICATIONS NOM DE FICHIERS DANS UN MÊME RÉPERTOIRE
C'est un tout petit code tout simple mais qui est pratique si on veut modifier rapidement les noms d...

{Visual Basic, VB6, VB.NET, VB 2005} CLASSE DE GESTION DES FICHIERS/DOSSIERS ==> INFOS (DATES, COPYRIGHT...), LISTING, COPIER, CORBEILLE, BOITES DE DIALOGUE ... LE TOUT PAR APIS
Ce code est une classe qui permet de faire différentes actions sur les fichiers et les dossiers, à s...

{Visual Basic, VB6, VB.NET, VB 2005} CRÉER DES FICHIERS DE LOG EN QUELQUES LIGNES
Ce code est trés simple et vous permet de créer des fichiers de log trés trés facilement. Il est ...

{Delphi} RENOMMEUR DE FICHIERS - X_RENFILES
Ceci est mon premier soft qui est basé sur des sources déjà présente sur delphifr. C'est mon premie...

{JAVA / J2EE} COPIER DES FICHIERS
Cette classe permet de copier des fichiers. De plus on peut définir des objets de ce type qui permet...