Compare 2 files and copy newest if required (Yes that old c drive chestnut!!)

Hi Guys

I hit a Security problem whilst running a exe from network, so I put my wee app on c drive.

Of course rolling out new stuff is wanted to write a loader for it.... so it loads checks date on myExe in cd drive then sees if there is new version at \\mynetworkpath\myExe. Then downloads this to c drive and brings programs in synch. Then launches myExe

So how do I do comparision???

cheers George
Who is Participating?
RonaldBiemansConnect With a Mentor Commented:
something lik this

        Dim fi1 As New System.IO.FileInfo("yourfileincd")
        Dim fi2 As New System.IO.FileInfo("yourfilenetworkpath")
        If fi1.CreationTime < fi2.CreationTime Then
        End If
Geo123Author Commented:
Whats the equivilent for VB6's "App.Path" in .Net??

How do I copy files?? I suspect security may kick in again... but nothing verntured.....

cheers George
fi1.CopyTo(newDestination)     ' or fi2.CopyTo ....




think those are probably the easiest to use in your case
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

If you don't want to move the FileInfo related files... use

IO.File.Copy("C:\File1.txt", "D:\File1.txt")

(or one of the many other ways)
Geo123Author Commented:
ok used the Application.StartupPath to cheat a wee bit as loader will be diff name. It copied the file down no bother.

1 last bit though... how do I launch the proper .net exe??? And close this loader down??

Thanks guys thats me nearly got this finished.... How am I going to split points though???


To start/load a file...

        Dim p As New Process
        p.StartInfo.FileName = myFullAppPath  ' myFullAppPath is your proper .net exe... so replace it accordingly


If your current program was loaded straight into a form, this should close it up.

If it was started in another way, let me know.

As for splitting the points... give Ronald a bigger share since he answered your original question
Geo123Author Commented:
ok thats great... program working away merily... thanks for help guys

S-Twilley will put up another question and if you could answer that...wee thing... you dont have to answer and will still give u points... just dont know how to split points

cheers George
To split points on the bottom of the page there should a button splits point :-)
Geo123Author Commented:
nope there wasnt Ronald...unless I am at wrong page!!
There should be a spilt points somewhere on this page :-)
Just above where you type in a post (i.e. the box im typing in now, you should see some links like this):

    Split Points  
    Question Bookmark: Add  
    Post a Comment: (Question and Answer tips)

but they'll only be their while the question is open (so it's too late for this one)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.