By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,640 Members | 2,094 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,640 IT Pros & Developers. It's quick & easy.

Searching for a directory by date

P: 12
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 and I donít know how to get around it.

Expand|Select|Wrap|Line Numbers
  1. Dim dteDate As Date
  2. Dim strFldr as String
  3.  
  4. 'Hard code directory just for example
  5. strFldr = c:\temp\ar123456
  6.  
  7. 'Set date to yesterdays date.
  8. dteDate = Today().AddDays(-1)
  9.  
  10. Dim dDir As New DirectoryInfo(fldTemp)
  11. MsgBox("Last access time was " & dDir.LastAccessTime)
Jan 30 '08 #1
Share this Question
Share on Google+
8 Replies


Expert 5K+
P: 8,434
Is this the actual code, or did you just type an approximation here? Because it looks to me as though line 5 wouldn't even compile (needs quotes).

And which line produces the error?
Jan 30 '08 #2

P: 12
Is this the actual code, or did you just type an approximation here? Because it looks to me as though line 5 wouldn't even compile (needs quotes).

And which line produces the error?
In retyping I misssed the quotes. And I get the Security Exception error at line 10, the Dim statement.
Jan 30 '08 #3

Expert 5K+
P: 8,434
My guess is the fldTemp in line 10 should be strFldr.

Beyond that, I think we'll need some input from someone who actually uses a later version than VB6.
Jan 31 '08 #4

Expert 5K+
P: 8,434
In retyping I misssed the quotes. And I get the Security Exception error at line 10, the Dim statement.
This is why we prefer copy and paste where possible. :) We often end up chasing a problem that actually doesn't exist in the code.
Jan 31 '08 #5

P: 12
This is why we prefer copy and paste where possible. :) We often end up chasing a problem that actually doesn't exist in the code.

Thanks for the tip.
And as to the name of the variable, you were correct, however i still get the same error after fixing that. Im stuck.
Feb 1 '08 #6

daniel aristidou
100+
P: 491
Are the files located in a security tight area??...
Feb 1 '08 #7

VACEPROGRAMER
100+
P: 168
Can you say do you using VB6 or 5 Or VB.net. I got a specaly code for you. I have made same program but I use for conttrol the OS "C:\WINDOWS\System32


*VACE*
Feb 2 '08 #8

Expert 5K+
P: 8,434
Thanks for the tip.
And as to the name of the variable, you were correct, however i still get the same error after fixing that. Im stuck.
Can you show us the actual code? So far I think we've fixed two problems that were in it.
Feb 2 '08 #9

Post your reply

Sign in to post your reply or Sign up for a free account.