Copy the entire contents of a directory in C#

I want to copy the entire contents of a directory from one location to another in C#. There doesn’t appear to be a way to do this using System.IO classes without lots of recursion. There is a method in VB that we can use if we add a reference to Microsoft.VisualBasic: new Microsoft.VisualBasic.Devices.Computer(). FileSystem.CopyDirectory( sourceFolder, … Read more

Fastest way to duplicate an array in JavaScript – slice vs. ‘for’ loop

In order to duplicate an array in JavaScript: Which of the following is faster to use? Slice method var dup_array = original_array.slice(); For loop for(var i = 0, len = original_array.length; i < len; ++i) dup_array[i] = original_array[i]; I know both ways do only a shallow copy: if original_array contains references to objects, objects won’t … Read more

How do I copy an object in Java?

Consider the code below: DummyBean dum = new DummyBean(); dum.setDummy(“foo”); System.out.println(dum.getDummy()); // prints ‘foo’ DummyBean dumtwo = dum; System.out.println(dumtwo.getDummy()); // prints ‘foo’ dum.setDummy(“bar”); System.out.println(dumtwo.getDummy()); // prints ‘bar’ but it should print ‘foo’ So, I want to copy the dum to dumtwo and change dum without affecting the dumtwo. But the code above is not doing … Read more