MSFN Forum: C# copy file help - MSFN Forum

Jump to content



Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

C# copy file help Copy all the files in a folder Rate Topic: -----

#1 User is offline   tony-inpo 

  • Group: Members
  • Posts: 4
  • Joined: 10-November 05

Posted 10 November 2005 - 05:18 PM

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


#2 User is offline   Dutchdre 

  • Newbie
  • Group: Members
  • Posts: 33
  • Joined: 19-January 05

Posted 11 November 2005 - 10:14 AM

Read this tutorial:

http://www.codeproject.com/csharp/copydire...esrecursive.asp

#3 User is offline   tony-inpo 

  • Group: Members
  • Posts: 4
  • Joined: 10-November 05

Posted 11 November 2005 - 02:42 PM

Nice one, cheers for that got it to work now

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2011 msfn.org
Privacy Policy