Coding Thread, A VB.net Program i don't have a Clue how todo! in Coding and Web Development; Hi everyone.
first of all. let me explain my situation.. we have our exchange do an automatic backup to our ...
28th March 2008, 09:53 AM #1
- Rep Power
A VB.net Program i don't have a Clue how todo!
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
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.
28th March 2008, 10:52 AM #2
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:
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.
Dim file1 As New System.IO.FileInfo("yourfilepath")
Dim result As Integer
result = DateTime.Compare(file1.LastModified, DateTime.Date)
Last edited by bizzel; 28th March 2008 at 11:05 AM.
28th March 2008, 11:19 AM #3
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.
Ron's Hard Tutorial - VBScript Date and Time Functions
28th March 2008, 11:45 AM #4
- Rep Power
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..
2nd June 2008, 02:57 PM #5
- Rep Power
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..
2nd June 2008, 03:36 PM #6
You're running it from a network location? Copy it onto the local hard drive, the framework gets stroppy about security otherwise.
2nd June 2008, 03:56 PM #7
- Rep Power
no. im running the application locally. its checking file infomation on a network file..
2nd June 2008, 10:24 PM #8
Never used it, but this sticks out a bit:
"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.
3rd June 2008, 11:23 AM #9
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.
By strawberry in forum Educational Software
Last Post: 27th January 2010, 02:16 PM
By boomam in forum How do you do....it?
Last Post: 24th January 2008, 09:46 AM
By sqdge in forum General Chat
Last Post: 1st August 2007, 08:11 AM
By contink in forum Windows
Last Post: 5th February 2007, 01:00 PM
By beeswax in forum Other Stuff
Last Post: 14th July 2006, 01:21 PM
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)