Solved

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

Posted on 2007-04-05
12
289 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
  • 5
  • 4
  • 3
12 Comments
 
LVL 67

Accepted Solution

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

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 85

Expert Comment

by:Mike Tomlinson
ID: 18860894
The VB.Net 2005 MoveDirectory() is natively "recursive".
0
 

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 85

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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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 85

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 85

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
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 …

760 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now