Solved

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

Posted on 2007-04-05
12
336 Views
Last Modified: 2013-11-26
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
0
Comment
Question by:webkiwi1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 3
12 Comments
 
LVL 67

Accepted Solution

by:
sirbounty earned 500 total points
ID: 18860824
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 18860881
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
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 18860894
The VB.Net 2005 MoveDirectory() is natively "recursive".
0
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 

Author Comment

by:webkiwi1
ID: 18860950
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
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 18860972
If you're just moving files without any extra rules/processing then you're doing way too much work!...
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18861173
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
 

Author Comment

by:webkiwi1
ID: 18861223
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
 
LVL 67

Expert Comment

by:sirbounty
ID: 18861236
Glad I could assist you. :^)
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 18861320
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
 

Author Comment

by:webkiwi1
ID: 18861359
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
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 18861403
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
 

Author Comment

by:webkiwi1
ID: 18863531
Awesome, I will give it a shot. Thanks and have a safe holiday weekend!
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Progress

622 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question