Hi,

I am using the showfolder method to get a location to a directory. I have this working and now I want to add a filename to that directory. I have the problem of the dir and filename joining together as one long filename or nothing happening. The problem : \ .

The code:

Private Sub CmdOk_Click() 'the ok button to start the process

Dim SFile As String
Dim Dest As String
Dim x As String
Dim Ans As String

CmdCancel.Enabled = False
CmdBrowse.Enabled = False
CmdOK.Enabled = False

SFile = App.path & "\Client.mdb"
Dest = TxtDest.Text
x = CopyDB(SFile, Dest)
Unload FrmBackup
Ans = MsgBox("Backup Complete!", vbInformation)

End Sub

Private Function CopyDB(SFile As String, Dest As String) As Long

Dim WFD As WIN32_FIND_DATA
Dim SA As SECURITY_ATTRIBUTES
Dim hFile As Long
Dim currFile As String

Call CreateDirectory(Dest, SA)
hFile = FindFirstFile(SFile, WFD)
If (hFile = INVALID_HANDLE_VALUE) Then
MsgBox "An error has occured locating the Database to Backup. Please retry."
Exit Function

End If

If hFile Then
currFile = Left$(WFD.cFileName, InStr(WFD.cFileName, Chr$(0)))

Call CopyFile(SFile, Dest & currFile, False)

End If
Call FindClose(hFile)
End Function

If i add a \ to the line like this :
Call CopyFile(SFile, Dest & "\" & Currfile, false)

then it will add an extra \ if you use d:\ ie d:\\

If I add it to the Dest like this:
Dest = TxtDest.Text & "\"

same thing happens. Is there a way to have vb tell it when it needs a \? Any help would be great and thanx in advance.