devxlogo

“File Exists?” Revision

“File Exists?” Revision

To adapt the tip “File Exists?” (see “101 Hot Tech Tips for VB Developers,” Supplement to the August 1996 issue of VBPJ, page 7) to a directory list box, it is necessary to control the error that occurs when the user selects the root (C:):

 Sub Dir1_Change	Dim File As String	File = Dir1.Path	If Right$(File, 1) = "" Then		File = File & "himem.sys"	Else		File = File & "" & "himem.sys"	End If	' Chuong Van Huynh's tip 	If Dir$(File) <> "" Then		MsgBox "himem.sys exists !"	End IfEnd Sub

Without testing to see if the path already ends with a backslash, as it would when it’s the root directory, an error occurs because of the string “c:\himem.sys.”

See also  Professionalism Starts in Your Inbox: Keys to Presenting Your Best Self in Email
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist