Check for a filepath on the local PC, create it if it doesn't exist

In the example below, the target path is being set in a dialog box.

On Error Resume Next
Dim workspace As New NotesUIWorkspace
Dim session As New NotesSession
Dim db As NotesDatabase
Set db = session.CurrentDatabase
Dim doctemp As NotesDocument    
Dim CostCenters As NotesItem
Dim TargetPath As String
TargetPath = "C:\Temp"
Set doctemp=db.CreateDocument
doctemp.ExpDlg_TargetPath = TargetPath
temp=workspace.DialogBox( "ExpDlg", True, True, False, False, False, False, "Custom Export", doctemp )
'Exit if the user clicks Cancel
If temp = False Then
	Print "Custom Export Cancelled!"
	Exit Sub
End If
'Retrieve the values specified by the user
Set CostCenters = doctemp.GetFirstItem("ExpDlg_CostCenters")		
TargetPath = doctemp.ExpDlg_TargetPath(0)

'*********************************Target Path Checks**************************************
Chdir TargetPath				'Check that the TargetPath exists
If Err = 76 Then				'If it did not exist
	Mkdir TargetPath 		'Create the TargetPath
	Err = 0					'Reset Error Number for next check
	Chdir TargetPath 		'Verify that the TargetPath was successfully created
	If Err = 76 Then 			'If it wasn't created successfully
		Msgbox "TargetPath does not exist or can't be created, please specify another.", 0 + 16, "Invalid Path"
		Goto TryAgain
	End If
End If

Posted by fbrefere001 on Monday June 24, 2002