Jump to content

C# copy file help


Recommended Posts

Hi, first post so hey everybody, hope someone can give me a hand here

I can copy files and folders but I have to do it individually. Here’s the code

string strOrigFile  = somelocation1; //defined by user
string strDestLoc = somelocation2; //defined by user

// Get the filename only
string strFileName = System.IO.Path.GetFileName(strOrigFile);

// Determine the full destination path including filename
string strDestFile = System.IO.Path.Combine(strDestLoc, strFileName);

// Copy the file
System.IO.File.Copy(strOrigFile, strDestFile);

How do I make it look for all the files in the Directory then copy them?

Thanks

Tony

Link to comment
Share on other sites


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...