Question Backup Files

36372

New member
Joined
Jul 17, 2012
Messages
2
Programming Experience
Beginner
Hi all, i'm very new to all this and i'm looking for a little help.

I've been using VB to create back ends to databases, and i'm ok with that.
But VB is so expansive, and I haven't had a chance to play with it all.
So i'm having a crack with console applications, I dl'd Visual Studio 2010 express on my laptop, so I haven't got all the supporting tutorials and sample applications that come with the full product.

I want to create something, which I think would be really simple, but pardon me if it isn't.
I've searched through this forums and the internet, trying to piece together bits of code to accomplish what i'm trying to.

Alas i'm still stuck.

Essentially all I want to do is make a backup of a file.

My idea was to have a file in any directory and then at the command line type e.g. - "backup.exe c:\test.txt"
which will result in creating a copy of test.txt in the same folder obviously with a different name. e.g. - test.001
As another idea I thought if the file is being backed up regularly, say back up at the end of the day, and you want to keep a number of days worth of backups
if you run "backup.exe c:\test.txt" - it will test if "test.001" exists, test if "test.002" exists and so on then finally creating "test.005"
Does that make any sense??? That's not important anyway, just an after thought.
My latest idea was to be able to right click on the file and then have an option in the context menu...

Any help would be most appreciated
Cheers Andy
 
It doesn't have to be the same folder... I'm not building the application to use, more to get an understanding of what you can do with VB, instead of the stuff i've been doing with it already, creating database applications etc... May implement something like it at a later date, but i was doing it more as a learning experience. I don't come from a programming background and i'm not a very pragmatic person. I'm a network engineer, but I work for a charity which means i'm also the network admin, software engineer, technical support etc... basically I even have to change the toner in the printer because everyone else in the organisation thinks that they would break it, if they had to do it... Ok, that last bit is a slight exaggeration.
Put simply I have to wear many hats and if I tried to specialised in one field then everything else would suffer.
Do you know any good tutorials or places i can go to learn for free!! or at the very least cheap??
I have some basic knowledge, but the whole object orientated approach has always eluded me, thought this would be a good example of a not very complex application to write, that i could keep developing and growing to start incorporating more functions and features.
There is so much information out there, although most of it leaves me scratching my head.
 
Some help to get you started:
You have to get the filename passed as argument to the application, see Main Procedure in Visual Basic
Then you should look to the System.IO namespace, especially the Path class that has the convenient ChangeExtension method, and File class that has methods like Exists and Copy.
You would further need a loop to go through numbers (for extensions 001,002 etc), declaring a Integer variable used as counter and using a Do loop would seem sensible. To expand a number to a padded string you can either use number.ToString("d3") which formats the number so, or string manipulation number.ToString.PadLeft(3, "0"c).
Putting these bits of information together and you can complete the first edition of this exercise in about 10 lines of code.
 
There is so much information out there, although most of it leaves me scratching my head.

Tell me about it! Unfortunately books tend to be a tad on the expensive side and if you don't get on with an author's style it's money wasted. There's not really what I would call a 'plain English' tutorial that I know of (Microsoft's own being the absolute opposite of that for the most part), and with a general search of the Internet you have the added problem of the VB6 retentives still dominating many listings. I'm afraid we have rather been left to muddle through and you're not helped with this particular project idea by the fact that most authors leave file manipulation (for reasons which escape me) until late meaning that you're assumed to know a lot already.

I'll keep my eyes open for a suitable resource but don't hold your breath!
 

Latest posts

Back
Top