![]() |
|
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Programmer
Join Date: Jun 2006
Location: Fayettehell, NC
Posts: 56
Rep Power: 3
![]() |
Creation date comparison for subdirectories
I need to move files from one drive to another. I have an application that will run on a given frequency to do this. Also, i do not want to move files that were moved the last time this application ran. Being that I am fairly new to programming, i figured i would think out loud and hopefully, if I a missing anything (other the grammer) that someone could point it out. Here are the steps I want to accomplish.
1. Check for drives that are mapped 2. Check last run date 3. Run, do a date compairson for each file in each directory on a given directory. If the file is newer, copy, if not, skip. 4. Renew last run date 5. Close I am making this a *.exe file so no one can mess w/ the code. People around here have tendency to think they are fixing things, when they are not. So, all the following is going to be put in a load event. So, for part 3 this is the code I am going to use. Dim path As String = "y:\filehere.txt" 'File for checking mapped drive
Dim file(), dir() As Object 'Array variables
Dim dirName, fileName, totFileLoc, endDir As String 'Used in For Each
Dim lastDate, currDate As DateTime 'Last run and Creation DateTime
dir = System.IO.Directory.GetDirectories("C:\application\reports")
For Each dirName In dir
file = System.IO.Directory.GetFiles(dirName)
For Each fileName In file
totFileLoc = dirName & fileName
currDate = System.IO.File.GetCreationTime(fileName)
If currDate > lastDate Then
endDir = "Y:\" & dirName & fileName
System.IO.File.Copy(totFileLoc, endDir)
End If
Next
NextI used the full Class.Object.Method names for learning purposes. In the future will be assigning the Call.Object to variables. Do you think this code will succesffuly get the directories and files and do the comparison? Bassically for each directory it will get a list of files and compare the dates. Once I get the function working, i'll build a "Working Bar" for the user interaction.
__________________
_Marshall_ "America has bred a society that is innocent and incapable of accepting responsibility, but yet, is able to place blame on others without guilt." |
|
|
|
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Delete File Before a Certain date | bobrivers | Bash / Shell Scripting | 4 | Nov 10th, 2005 4:43 AM |
| date question | rjbrynteson | ASP | 3 | Oct 19th, 2005 3:24 PM |
| Php Postgresql Class | Pizentios | Show Off Your Open Source Projects | 15 | Jun 28th, 2005 9:55 AM |
| Date Method | Abyss | Java | 2 | Apr 10th, 2005 8:47 AM |
| Enquiry About Visual Basic Project | kbkhoo5053 | Visual Basic | 13 | Feb 15th, 2005 2:20 AM |