Click here to Skip to main content
14,826,961 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello friends, please I need help concerning this issue.
I would like to convert file path. For example, a file path is
C:\Documents and Settings\Uncle Joe\My Document\

and I would like to convert it to something like

I also would like to know how I can encode an URL.
For example: an URL is

and after encoding it should become something like

Please if it is not possible using VB.NET kindly give me another means to do it.
I need to get these things done.
Updated 20-Nov-11 4:41am

DOS 8.3 path and file names need the kernel32 funtion GetShortPathName:
Private Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long

Public Function GetShortName(ByVal sLongFileName As String) As String
Dim lRetVal As Long, sShortPathName As String, iLen As Integer
sShortPathName = Space(255)
iLen = Len(sShortPathName)
lRetVal = GetShortPathName(sLongFileName, sShortPathName, iLen)
GetShortName = Left(sShortPathName, lRetVal) 
End Function
First example shows something which looks like DOS short names as they were introduced with introduction of NTFS for compatibility with legacy software (then this example is written incorrectly: blank character is not allowed). Do you need compatibility with code written for MS-DOS or something like that? Better avoid it by all means. I don't think you really need to use such names, frankly.

As to the second conversion, it looks like URLEncode. Use the method System.Web.HttpServerUtility.UrlEncode,[^].


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900