+ Post New Thread
Results 1 to 9 of 9
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 ...
  1. #1

    Join Date
    Feb 2008
    Location
    Stevenage, Hertfordshire
    Posts
    111
    Thank Post
    3
    Thanked 8 Times in 5 Posts
    Rep Power
    15

    A VB.net Program i don't have a Clue how todo!

    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!!

  2. #2
    bizzel's Avatar
    Join Date
    Jul 2007
    Location
    Cambridge
    Posts
    654
    Thank Post
    102
    Thanked 204 Times in 72 Posts
    Rep Power
    51
    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.
    Last edited by bizzel; 28th March 2008 at 10:05 AM.

  3. #3
    Jona's Avatar
    Join Date
    May 2007
    Location
    Cranleigh
    Posts
    469
    Thank Post
    14
    Thanked 50 Times in 48 Posts
    Rep Power
    23
    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/scr....mspx?mfr=true
    Ron's Hard Tutorial - VBScript Date and Time Functions

  4. #4

    Join Date
    Feb 2008
    Location
    Stevenage, Hertfordshire
    Posts
    111
    Thank Post
    3
    Thanked 8 Times in 5 Posts
    Rep Power
    15
    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..

    VB.NET

  5. #5

    Join Date
    Feb 2008
    Location
    Stevenage, Hertfordshire
    Posts
    111
    Thank Post
    3
    Thanked 8 Times in 5 Posts
    Rep Power
    15
    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..
    Attached Images Attached Images

  6. #6
    bizzel's Avatar
    Join Date
    Jul 2007
    Location
    Cambridge
    Posts
    654
    Thank Post
    102
    Thanked 204 Times in 72 Posts
    Rep Power
    51
    You're running it from a network location? Copy it onto the local hard drive, the framework gets stroppy about security otherwise.

  7. #7

    Join Date
    Feb 2008
    Location
    Stevenage, Hertfordshire
    Posts
    111
    Thank Post
    3
    Thanked 8 Times in 5 Posts
    Rep Power
    15
    no. im running the application locally. its checking file infomation on a network file..

  8. #8

    Join Date
    Jan 2006
    Location
    Surburbia
    Posts
    2,178
    Thank Post
    74
    Thanked 307 Times in 243 Posts
    Rep Power
    115
    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.

  9. #9
    bizzel's Avatar
    Join Date
    Jul 2007
    Location
    Cambridge
    Posts
    654
    Thank Post
    102
    Thanked 204 Times in 72 Posts
    Rep Power
    51
    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.

SHARE:
+ Post New Thread

Similar Threads

  1. text to speech program
    By strawberry in forum Educational Software
    Replies: 5
    Last Post: 27th January 2010, 01:16 PM
  2. Program security.
    By boomam in forum How do you do....it?
    Replies: 7
    Last Post: 24th January 2008, 08:46 AM
  3. ToDo List
    By sqdge in forum General Chat
    Replies: 14
    Last Post: 1st August 2007, 07:11 AM
  4. Technet vs' Partner Program
    By contink in forum Windows
    Replies: 3
    Last Post: 5th February 2007, 12:00 PM
  5. crossword clue
    By beeswax in forum Other Stuff
    Replies: 4
    Last Post: 14th July 2006, 12:21 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •