I have a third party program that runs several scheduled batch routines every night. Each type of batch routine creates a folder in the C:\Temp directory. Inside the folders are error reports that are txt files. I am writing a program that will also be run as a scheduled routine, but it will look for the most recent set of folders (tg*, ar*, mdb* are the folder strings) and read the txt files looking for certain strings. If the strings exist it will write the string out to a separate file and that file will contain a listing of all errors for all scheduled batch routines. That file will in turn either be emailed to myself or I will have a shortcut to it on my desktop so I can open it first thing in the morning to find out if any of the routines had errors.
Now that I have thoroughly confused everyone, I need to know how to search for a folder with the above string by date. I have the following code which I thought would do it but I keep getting a SecurityException error at line 10 (Dim dDir) and I don’t know how to get around it.
Code: ( vbnet )
Expand|Select|Wrap|Line Numbers
- Dim dteDate As Date
- Dim fldTemp as String
- 'Hard code directory just for example
- fldTemp = "c:\temp\ar123456"
- 'Set date to yesterdays date.
- dteDate = Today().AddDays(-1)
- Dim dDir As New DirectoryInfo(fldTemp)
- MsgBox("Last access time was " & dDir.LastAccessTime)