Copy Directory, Sub directories and all files from local drive to network.

OK, I have spent too long searching for a good answer to this one...

Using VB.NET, Visual Studio 2005.

Need a SIMPLE function that I can call to copy the contents from a directory (including files and subdirectories and files) on the local drive to a networked drive...permissions etc not an issue.
Overwrites etc ok, but maybe an option to check for duplicates and only copy unique would be nice.

Also need another function to delete the contents of the local directory if necessary.

Thanks
Michael
webkiwi1Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
sirbountyConnect With a Mentor Commented:
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Use My.Computer.FileSystem.MoveDirectory():
http://msdn2.microsoft.com/en-us/library/519wkbx1.aspx

Something like...

    My.Computer.FileSystem.MoveDirectory("c:\test1", "c:\test2", Microsoft.VisualBasic.FileIO.UIOption.AllDialogs)
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
The VB.Net 2005 MoveDirectory() is natively "recursive".
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
webkiwi1Author Commented:
Sirbounty, you are a scholar and a gentleman...I think!
Thanks for the quick response, worked perfect...points awarded!

Thanks for the info Idle Mind.
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
If you're just moving files without any extra rules/processing then you're doing way too much work!...
0
 
sirbountyCommented:
Thanx...but now that I've seen Idle_Mind's suggestion, I'm inclined to think that may have been a better option for you...?  Though I'm not sure exactly what you're trying to accomplish...
0
 
webkiwi1Author Commented:
Not sure about too much work, I cut and paste the code given to me by SirBounty and it worked...seemed pretty simple!

I will keep the MSDN stuff handy, but at this point do not have the time to work through it and figure it out. Iasked for a simple founction and got what I asked for, which was the ability to copy a folder, files, sub directories and files to a netowrk drive, and only copy new files.
0
 
sirbountyCommented:
Glad I could assist you. :^)
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Whatever floats your boat...   =)

There isn't anything to "figure out" really though.  It's a "one liner" just like I showed:

    My.Computer.FileSystem.MoveDirectory(yourSourceFolderHere, yourTargetFolderHere)

That's LITERALLY it.

The vesion I gave above in my previous posts has the extra flag that shows the default windows operating system progress dialog while the files are moved.

Good luck...  =)
0
 
webkiwi1Author Commented:
Thanks Idle Mind, the progress dialog would be a great feature. I appreciate you taking the time to provide the example in a simple one liner like you last post. THAT is what I needed. I will have to try it out.

Microsoft do not make things simple and whenever I get sent to a MSDN page it can mean a lot of time figuring out options, syntax etc etc.

Do I need to import anything with your solution or will it work as is?
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
It should work "as is".

...and I agree, the MSDN pages are sometimes hard to read and interpret.  =)

By the way, the "My.xxx.yyy" functions are NEW in VB.Net 2005.
0
 
webkiwi1Author Commented:
Awesome, I will give it a shot. Thanks and have a safe holiday weekend!
0
All Courses

From novice to tech pro — start learning today.