|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Alternate NameDoes anyone know how I can get the Alternate Name for a file using VB? You
know that short file names that are displayed when you issue the "DIR /X" DOS command. I can get the long file name using System.IO.FileInfo class. Only problem is this class doesn't provide the alternate name (short name). Greg Larsen wrote:
> Does anyone know how I can get the Alternate Name for a file using VB? You You use the GetShortPathName API function...> know that short file names that are displayed when you issue the "DIR /X" DOS > command. I can get the long file name using System.IO.FileInfo class. Only > problem is this class doesn't provide the alternate name (short name). Option Explicit On Option StrictOn Imports System.Text Imports Sytem.Runtime.InteropServices .... Private Declare Auto Function GetShortPathName ( _ ByVal lpszLongPath As String, _ ByVal lpszShortPath As System.Text.StringBuilder, _ ByVal cchBuffer As Integer) As Integer .... Public Function GetShortPathName (ByVal LongPathName As String) As String Dim buffer As New StringBuilder (260) Dim returnValue As Integer = GetShortPathName ( _ LongPathName, buffer, buffer.Capacity) ' you should check the return here... If returnValue = 0, then there ' was a win32 error. If returnValue > buffer.Capacity, then you need to ' increase the buffer size to returnValue and call again. Return buffer.ToString () End Function HTH, -- Tom Shelton [MVP]
Xcopy Install of VB Classic Application
How to Use a Screen Saver app within My Application? scope of command and garbage collection Object from variable Applying word styles using VB .Net using up too much memory and is slow SET ARITHABORT ON: Why (not)? Web Service Question about a conversion project Inline SQL vs stored procs on SQL Server 7 and 2000 Off Topic - sorry |
|||||||||||||||||||||||