Converting File Names

Converting File Names

VB4’s commands for dealing with file names (such as KILL, MKDIR, andFILECOPY) support long file names without programmer interaction. A numberof the Win95 API functions will return only the short name, and you’llnotice a number of short file name entries if you’re digging through theregistration database. Therefore, occasionally you’ll need to convert ashort file name into a long file name. This function lets you pass a long file name with no ill effects. Thefile must exist for the conversion to succeed. Because this routine usesDir$ and “walks” the path name to do its work, it will not impressyou with its speed:

 Function sLongName(sShortName As String) As String	'sShortName - the provided file name, 	'fully qualified, this would usually be 	'a short file name, but can be a long file name	'or any combination of long / short parts	'RETURNS: the complete long file name, 	'or "" if an error occurs	'an error would usually indicate 	'that the file doesn't exist	Dim sTemp As String	Dim sNew As String	Dim iHasBS As Integer	Dim iBS As Integer	If Len(sShortName) = 0 Then Exit Function	sTemp = sShortName	If Right$(sTemp, 1) = "" Then		sTemp = Left$(sTemp, Len(sTemp) - 1)		iHasBS = True	End If	On Error GoTo MSGLFNnofile	If InStr(sTemp, "") Then		sNew = ""		Do While InStr(sTemp, "")			If Len(sNew) Then				sNew = Dir$(sTemp, 54) & "" & sNew			Else				sNew = Dir$(sTemp, 54)				If sNew = "" Then					sLongName = sShortName					Exit Function				End If			End If			On Error Resume Next			For iBS = Len(sTemp) To 1 Step -1				If ("" = Mid$(sTemp, iBS, 1)) Then					'found it					Exit For				End If			Next iBS			sTemp = Left$(sTemp, iBS - 1)		Loop		sNew = sTemp & "" & sNew	Else		sNew = Dir$(sTemp, 54)	End IfMSGLFNresume:	If iHasBS Then		sNew = sNew & ""	End If	sLongName = sNew	Exit FunctionMSGLFNnofile:	sNew = ""	Resume MSGLFNresumeEnd Function
Share the Post:
Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several

data fivetran pricing

Fivetran Pricing Explained

One of the biggest trends of the 21st century is the massive surge in analytics. Analytics is the process of utilizing data to drive future decision-making. With so much of