Click here to Skip to main content
15,881,380 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\manga.zip

and I would like to convert it to something like
C:\DOCUMEN~\Uncl~\MY DOC~\manga.zip

I also would like to know how I can encode an URL.
For example: an URL is
http://www.google.com/search.php

and after encoding it should become something like
http%3A%2F%2Fwww.google.com%2Fsearch.php

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

DOS 8.3 path and file names need the kernel32 funtion GetShortPathName:
VB
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
 
Share this answer
 
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, http://msdn.microsoft.com/en-us/library/zttxte6w.aspx[^].

—SA
 
Share this answer
 

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