Q:

Folder and file operations

I am new to VB but I need to achieve these in my project using VB.
I have a file target.file at local. There is a target folder on network server. There are several hundred folders under target. There are backup folders under some of those folders.
I need to copy target.file to those folders under the target folder, but only copy/replace if there is already a target.file existing. If the target.file exists, copy and replace the file to the backup folder if the backup folder exists. If not, create the backup folder first.

A:

You need to use the methods in System.IO namespace. Take a look at the Documentation, there is a lot of interesting and useful classes, specially File, Directory and Path.
This are the methods that looks like you will need:

File.Exists(): Checks if a file exists on the path given.
File.Copy(): Copies the file on the path given.
Directory.Exists(): Checks if a directory exists on the path given.
Directory.CreateDirectory(): Creates all the directories that doesnt exists on the path given.

However, you didn't need to check if the file exists because you can copy directly with the overwrite option enabled:
File.Copy(sourceFile, destPathFile, True) 'True for overwrite

