473,394 Members | 1,755 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Alternate Name

Does 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).
May 24 '06 #1
1 1300

Greg Larsen wrote:
Does 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).


You use the GetShortPathName API function...

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]

May 24 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Matt | last post by:
I want to produce colors in alternate rows in the table. The following will produce blue color on every row. So my problem is to figure out to count the records. If it is odd record, then do <tr...
7
by: Matt B | last post by:
I have a need to alternate output row colour where not every row in the sequence is output, so I cannot base the colour on whether position() is odd or even. e.g. .... <xsl:for-each...
15
by: phil-news-nospam | last post by:
This question is borderline between language and programming, but I want to focus more on the language standards issue, rather than the programming issue, so I am posting here. I have a number...
1
by: Eric Lindsay | last post by:
I am trying to understand the differences between and uses of persistent, default and alternate styles. I have read http://www.w3.org/TR/REC-html40/present/styles.html section 14.3.2 on...
1
by: Sean Burns | last post by:
Hello, I am busy creating my first XSD and folloing the examples and tutorials from "everywhere" I came up with an xsd that does the job, but I need a alternate to "sequence" because I do not...
5
by: Michael R | last post by:
Searching the net I've found a simple technique to add row numbers and alternate colors (for the even and the uneven row) to a continuous form. 1st step: Create a textbox, send it to background...
10
by: Debajit Adhikary | last post by:
I'm writing this little Python program which will pull values from a database and generate some XHTML. I'm generating a <tablewhere I would like the alternate <tr>'s to be <tr class="Even">...
5
by: OldBirdman | last post by:
Assume 2 tables tblP {Primary Table} tblP.Key {AutoNumber and all that} tblP.Name {Name of EE, Movie, Bird Species, or Whatever} tblA {Alternate Table} tblA.Key {AutoNumber and...
0
by: zgh1970 | last post by:
Hi, All, I have some question on the alternate server for the DB connection on db2 connect server. There is one db2 connection to one host database on the server with the following cfg: ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.