Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21185

how do i know if a backup already exists?and how to format it with time and date

$
0
0
2 things
i have a backup form that i backup my DB
im trying to see if the same backup exists and if it does exist"msgbox overwrite yes no?
second i tried to show in the backup folder the date time month year i get error:
cannot copy HairDesign, the file name, directory name,or volume label syntex is incorrect.
this is my code for the backup DB:
Code:

Public Function fBrowseForFolder(hWndOwner As Long, sPrompt As String) As String
Dim iNull    As Integer
Dim lpIDList As Long
Dim lresult  As Long
Dim sPath    As String
Dim udtBI    As BrowseInfo

With udtBI
    .hWndOwner = hWndOwner
    .lpszTitle = lstrcat(sPrompt, "")
    .ulFlags = BIF_RETURNONLYFSDIRS
End With

lpIDList = SHBrowseForFolder(udtBI)

If lpIDList Then
    sPath = String$(MAX_PATH, 0)
    lresult = SHGetPathFromIDList(lpIDList, sPath)
    Call CoTaskMemFree(lpIDList)
   
    iNull = InStr(sPath, vbNullChar)
    If iNull Then sPath = Left$(sPath, iNull - 1)
End If

fBrowseForFolder = sPath

End Function

Code:

Public Sub DoBackup(strSourcePath As String, strDestinationPath As String)
screen.MousePointer = vbHourglass
On Error Resume Next
Dim lFileOp  As Long
Dim lresult  As Long
Dim lFlags  As Long
Dim SHFileOp As SHFILEOPSTRUCT
Dim strSourceDir As String
Dim strDestinationDir As String

screen.MousePointer = vbHourglass
BackupFolderName = strDestinationPath
MkDir BackupFolderName & "\Backup  " & Format(Now, "dddd, dd  MMMM  yyyy - HH:MM:SS")
lFileOp = FO_COPY
lFlags = lFlags And Not FOF_SILENT
lFlags = lFlags Or FOF_NOCONFIRMATION
lFlags = lFlags Or FOF_NOCONFIRMMKDIR
lFlags = lFlags Or FOF_FILESONLY
With SHFileOp
    .wFunc = lFileOp
    .pFrom = strSourcePath & vbNullChar
    .pTo = strDestinationPath & "\Backup  " & Format(Now, "dddd, dd  MMMM  yyyy - HH:MM:SS") & vbNullChar
    .fFlags = lFlags
End With
lresult = SHFileOperation(SHFileOp)
screen.MousePointer = vbDefault
MsgBox "Backup Succeeded", vbInformation
 frmBackupDba.txtDestination.text = ""
screen.MousePointer = vbNormal
frmBackupDba.Hide

End Sub


Viewing all articles
Browse latest Browse all 21185

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>