TornUp Posted March 28, 2008 Posted March 28, 2008 Hi everyone. first of all. let me explain my situation.. we have our exchange do an automatic backup to our domain controller every morning at 2am.. im trying to make a VB program that checks the "Last Modify" date, and compairs it to our date.. If: dates = the same then kill the application Else BIG RED SCREEN WITH WARNING TEXT ON i will set it on my "startup" folder, then every time i log on, WOOO problems im having: Getting the modifyed date(and being able to strip the time off the end of it(we don't want to compair time! times won't match, only the date will!)) Getting todays date(and once again stripping the time off) i need your help, if somone to tell me how to get these 2 dates into a string it would be amazin! i have honestly tryed for hours! iv only just started Vb.net, so im not majorly clued up on it all yet. some help??? cheers!!
bizzel Posted March 28, 2008 Posted March 28, 2008 (edited) I'm very rusty on VB, I'm afraid but I can tell you that you're probably looking for DateTime.Compare. You could do something like this: Dim file1 As New System.IO.FileInfo("yourfilepath") Dim result As Integer result = DateTime.Compare(file1.LastModified, DateTime.Date) If result is 0, there's no difference. If it's less than 0, dt1 is earlier than dt2 and if it's greater than 0, dt1 is later than dt2. If that code doesn't work, someone who's actually written some VB in the last year might be able to do something with it. Edited March 28, 2008 by bizzel
Jona Posted March 28, 2008 Posted March 28, 2008 For what your doing it sounds like VB.NET might be over-engineered / overly complex. You might be better off using VBS or something similar. See: http://www.microsoft.com/technet/scriptcenter/guide/sas_scr_qdsc.mspx?mfr=true Ron's Hard Tutorial - VBScript Date and Time Functions
TornUp Posted March 28, 2008 Author Posted March 28, 2008 The problem i seem to be having is stripping the time off the end of the string.. if i can get rid of that.. i will be able to do this! its complaing about some sort of bloody access rights now aswell i can't even retreave the RAW data infomation and output it as a msgbox, let alone put it down to a string and remove the crap on the end.. :mad:VB.NET
TornUp Posted June 2, 2008 Author Posted June 2, 2008 This is the error im currently having, i stripped out all the caparison code, and just got it to output into a MSGBOX but i keep getting this error. and as usual, microsoft help is no help! screenshot should(first time using uploaded) attatched..
bizzel Posted June 2, 2008 Posted June 2, 2008 You're running it from a network location? Copy it onto the local hard drive, the framework gets stroppy about security otherwise.
TornUp Posted June 2, 2008 Author Posted June 2, 2008 no. im running the application locally. its checking file infomation on a network file..
PiqueABoo Posted June 2, 2008 Posted June 2, 2008 Never used it, but this sticks out a bit: My.Computer.FileSystem.GetFileInfo "My Computer" could be a problem considering the file is on some other computer. Get rid of that and try it the System.IO.FileInfo way bizzel mention back in March.
bizzel Posted June 3, 2008 Posted June 3, 2008 Basically, that error boils down to "nuh uh, I don't have permission to access that item", which could be a lot of things. In this case, it's telling you that it doesn't have permission to read. Assuming that you can access the file with explorer, I'd give System.IO.FileInfo a spin and see if that changes anything.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now