Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old May 14th, 2005, 10:50 PM   #1
harjit
Newbie
 
Join Date: May 2005
Posts: 1
Rep Power: 0 harjit is on a distinguished road
Unhappy copying files first before deleting them

I have a program that purges files after a certain amount of days.My problem
is now to move the files that I wish to delete to an archive folder first before deleting them permanently so that users can still access those files if there's a need to.How do I do this?Can someone help me please?The codes are as follows (VB6)

Private Sub Form_Activate()
Dim fso As New FileSystemObject
Dim RootPath As String
Dim Report As String
Dim Path As String
Dim KeepDay As Integer
Dim root As Folder
Dim Fol1 As Folder
Dim Fol2 As Folder
Dim Fol3 As Folder
Dim File1 As File
Dim File2 As File
Dim vStart As Date
Dim vEnd As Date
Dim DelNum As Long
DelNum = 0
vStart = Now
RootPath = "E:\Xfiles\WIPFS\_AccMgr\Thruput\"
Open App.Path & "\Parameter.txt" For Input As #1
Do Until (EOF(1) = True)
KeepDay = 0
Input #1, KeepDay
Loop
Close #1
Open App.Path & "\DeletedFile.txt" For Output As #2
Set root = fso.GetFolder(RootPath)
For Each Fol1 In root.SubFolders
Set Fol2 = fso.GetFolder(RootPath & Fol1.Name)
For Each File1 In Fol2.Files
If DateDiff("d", File1.DateLastModified, Date) > KeepDay Then
Print #2, RootPath & Fol1.Name & "\" & File1.Name,
DateDiff("d", File1.DateLastModified, Date)
lblFile.Caption = RootPath & Fol1.Name & "\" & File1.Name
fso.DeleteFile RootPath & Fol1.Name & "\" & File1.Name
DelNum = DelNum + 1
End If
DoEvents
Next
Next
Close #2
vEnd = Now
Open App.Path & "\ExecutionLog.txt" For Append As #1
Print #1, "Start: " & vStart, "End: " & vEnd, "Successfully Delete " & DelNu
m & " Files."
Close #1
End
End Sub

I tried using this line fso.copyfile source, destination its suppose to be correct but it keeps giving me an error.Is it suppose to look like this

fso.copyfile "C:/harj" , "C:/harj/harj_copy"

OR

source = "C:/harj"
destination = "C:/harj/harj_copy"
fso.copyfile source, destination

Where exactly do I put these lines in my code?Please guide me as Im new to VB.Thank u so much in advance.
harjit is offline   Reply With Quote
Old May 15th, 2005, 7:05 AM   #2
Rory
Expert Programmer
 
Rory's Avatar
 
Join Date: Jan 2005
Location: London
Posts: 542
Rep Power: 4 Rory is on a distinguished road
Send a message via MSN to Rory
Quote:
Originally Posted by harjit
I tried using this line fso.copyfile source, destination its suppose to be correct but it keeps giving me an error.Is it suppose to look like this

fso.copyfile "C:/harj" , "C:/harj/harj_copy"

OR

source = "C:/harj"
destination = "C:/harj/harj_copy"
fso.copyfile source, destination

Where exactly do I put these lines in my code?Please guide me as Im new to VB.Thank u so much in advance.
There's a built in function FileCopy(Source, Destination).
Rory is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 12:01 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC