tamilway
asked on
I want backup & restore module.
Actualy I developing a accounting software for our organisation. I want to add the Backup & Restore Utility in my program.
Is there any readymade modules just i add?
Otherwise how can i write the coding?
Assist me.
Is there any readymade modules just i add?
Otherwise how can i write the coding?
Assist me.
yes ive made one doesnt support tape drives though you can download it from http://lightning.prohosting.com/~shell123 search for shfileoperation under the snipplets section
sorry man thats the wrong sample and allthough its perfect for backing up files and directories i dont have the sample i was thinking of posted anywere on the net so let me get home and post you another answer sorry that sample is basically the same as the module ive created only the new one has restore capability
sdland1 changed their proposed answer to a comment
'Hey be sure and visit 'http://lightning.prohosting.com/~'shell123 over three thousand examples 'and growing daily
Const FO_COPY = &H2
Const FO_DELETE = &H3
Const FO_MOVE = &H1
Const FO_RENAME = &H4
Const FOF_ALLOWUNDO = &H40
Const FOF_SILENT = &H4
Const FOF_NOCONFIRMATION = &H10
Const FOF_RENAMEONCOLLISION = &H8
Const FOF_NOCONFIRMMKDIR = &H200
Const FOF_FILESONLY = &H80
Const FOF_MULTIDESTFILES = &H1
Private Type SHFILEOPSTRUCT
hwnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
fAborted As Boolean
hNameMaps As Long
sProgress As String
End Type
Private Declare Function SHFileOperation Lib "shell32.dll" _
Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long
Private Function Backup()
' youll need to add your files with paths to a listbox visible or invisible example c:\temp\vb\plop\something. doc this example uses list1
'theres all kinds of great ways to automatically fill a list box with files from a specified directory
'set like this the program will not prompt you to create folders and will rename a file when a file with the same name is found in the destination directory
'this example will display the windows copy file dialog if you wish to disable this simply add FOF_SILENT fFlags field below example .fFlags = FOF_NOCONFIRMMKDIR + FOF_RENAMEONCOLLISION + FOF_SILENT
End Function
Dim iCount As Integer
Dim strFullPath As Variant
For iCount = 0 To List1.ListCount - 1
strFullPath = Mid(List1.List(iCount) & vbNullChar, 3) 'gets direcctory info from list box
Dim lFileOp As Long
Dim lresult As Long
Dim lFlags As Long
Dim SHFileOp As SHFILEOPSTRUCT
lFileOp = FO_COPY
With SHFileOp
.wFunc = lFileOp
.pFrom = List1.List(iCount) & vbNullChar & vbNullChar
.pTo = txtPath.Text & strFullPath
.fFlags = FOF_NOCONFIRMMKDIR + FOF_RENAMEONCOLLISION
End With
lresult = SHFileOperation(SHFileOp)
'
' If User hit Cancel button while operation is in progress,
' the fAborted parameter will be true
Screen.MousePointer = vbDefault
If lresult <> 0 Or SHFileOp.fAborted Then Exit Function
End If
Next iCount
End Function
Private Function Restore()
' to restore files youll need two text boxes text1 text2 you can change this below easily to use any you like or can specifie the source and dstination in place of the textboxs
'Text2.Text=source Text1=destination
'I just threw this together so flip out it works great shfileoperation is straight awsome
End Function
Dim iCount As Integer
Dim strFullPath As Variant
Dim lFileOp As Long
Dim lresult As Long
Dim lFlags As Long
Dim SHFileOp As SHFILEOPSTRUCT
lFileOp = FO_COPY
With SHFileOp
.wFunc = lFileOp
.pFrom = Text2.Text & "\" & "*.*"
.pTo = Text1.Text
.fFlags = FOF_NOCONFIRMATION + FOF_NOCONFIRMMKDIR
End With
lresult = SHFileOperation(SHFileOp)
'
' If User hit Cancel button while operation is in progress,
' the fAborted parameter will be true
Screen.MousePointer = vbDefault
If lresult <> 0 Or SHFileOp.fAborted Then Exit Function
MsgBox "Restore Completed Succesfully", vbOKOnly + vbExclamation, "Hell Yeah "
End Function
Const FO_COPY = &H2
Const FO_DELETE = &H3
Const FO_MOVE = &H1
Const FO_RENAME = &H4
Const FOF_ALLOWUNDO = &H40
Const FOF_SILENT = &H4
Const FOF_NOCONFIRMATION = &H10
Const FOF_RENAMEONCOLLISION = &H8
Const FOF_NOCONFIRMMKDIR = &H200
Const FOF_FILESONLY = &H80
Const FOF_MULTIDESTFILES = &H1
Private Type SHFILEOPSTRUCT
hwnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
fAborted As Boolean
hNameMaps As Long
sProgress As String
End Type
Private Declare Function SHFileOperation Lib "shell32.dll" _
Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long
Private Function Backup()
' youll need to add your files with paths to a listbox visible or invisible example c:\temp\vb\plop\something.
'theres all kinds of great ways to automatically fill a list box with files from a specified directory
'set like this the program will not prompt you to create folders and will rename a file when a file with the same name is found in the destination directory
'this example will display the windows copy file dialog if you wish to disable this simply add FOF_SILENT fFlags field below example .fFlags = FOF_NOCONFIRMMKDIR + FOF_RENAMEONCOLLISION + FOF_SILENT
End Function
Dim iCount As Integer
Dim strFullPath As Variant
For iCount = 0 To List1.ListCount - 1
strFullPath = Mid(List1.List(iCount) & vbNullChar, 3) 'gets direcctory info from list box
Dim lFileOp As Long
Dim lresult As Long
Dim lFlags As Long
Dim SHFileOp As SHFILEOPSTRUCT
lFileOp = FO_COPY
With SHFileOp
.wFunc = lFileOp
.pFrom = List1.List(iCount) & vbNullChar & vbNullChar
.pTo = txtPath.Text & strFullPath
.fFlags = FOF_NOCONFIRMMKDIR + FOF_RENAMEONCOLLISION
End With
lresult = SHFileOperation(SHFileOp)
'
' If User hit Cancel button while operation is in progress,
' the fAborted parameter will be true
Screen.MousePointer = vbDefault
If lresult <> 0 Or SHFileOp.fAborted Then Exit Function
End If
Next iCount
End Function
Private Function Restore()
' to restore files youll need two text boxes text1 text2 you can change this below easily to use any you like or can specifie the source and dstination in place of the textboxs
'Text2.Text=source Text1=destination
'I just threw this together so flip out it works great shfileoperation is straight awsome
End Function
Dim iCount As Integer
Dim strFullPath As Variant
Dim lFileOp As Long
Dim lresult As Long
Dim lFlags As Long
Dim SHFileOp As SHFILEOPSTRUCT
lFileOp = FO_COPY
With SHFileOp
.wFunc = lFileOp
.pFrom = Text2.Text & "\" & "*.*"
.pTo = Text1.Text
.fFlags = FOF_NOCONFIRMATION + FOF_NOCONFIRMMKDIR
End With
lresult = SHFileOperation(SHFileOp)
'
' If User hit Cancel button while operation is in progress,
' the fAborted parameter will be true
Screen.MousePointer = vbDefault
If lresult <> 0 Or SHFileOp.fAborted Then Exit Function
MsgBox "Restore Completed Succesfully", vbOKOnly + vbExclamation, "Hell Yeah "
End Function
ASKER
I can't get the correct one.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.