Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with finding a path

Status
Not open for further replies.

devinci

MIS
Feb 15, 2002
46
CA
I want to be able to search to see if a shortcut to an executable file exists. This is the code that I have. The thing is that the shortcut exists but it always send me false when it search for the path.

Thanks..

Public Function FileExists(FileName As String) As Boolean

If Dir(FileName) = "" Then
FileExists = False
Else
FileExists = True
End If

End Function

Private Sub Form_Load()

fDeleteShortcutOnDesktop

End Sub

Sub fDeleteShortcutOnDesktop()

Dim WSHShell As IWshRuntimeLibrary.IWshShell_Class
Dim WSHShortcut As IWshRuntimeLibrary.IWshShortcut_Class
Dim strFullFilePathName As String
Dim strDesktopPath As String
Dim strFileName As String
Dim strPath As String

' Create a Windows Shell Object
Set WSHShell = New IWshRuntimeLibrary.IWshShell_Class

' Read desktop path using WshSpecialFolders object
strDesktopPath = WSHShell.SpecialFolders.Item("Desktop")
strDesktopPath = strDesktopPath & "\" & gstrApplicationName & ".dat"
If FileExists(strDesktopPath) = True Then
'delete
End If

Set WSHShell = Nothing

End Sub

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top