Jump to content

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


Recommended Posts

Posted

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 :D

 

 

 

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???:cool:

 

cheers!!

Posted (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 by bizzel
Posted

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 :rolleyes: 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

  • 2 months later...
Posted

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

code-error.jpg

Posted
You're running it from a network location? Copy it onto the local hard drive, the framework gets stroppy about security otherwise.
Posted

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.

Posted
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.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...