-----------------------------------------------
string path = Server.MapPath(@"photos\test2");
string sourcepath = Server.MapPath(@"photos\test");
System.IO.Directory.CreateDirectory(path);
string[] files = System.IO.Directory.GetFiles(sourcepath);
foreach (string s in files)
{
string filename = System.IO.Path.GetFileName(s);
string destfile = System.IO.Path.Combine(sourcepath, filename);
System.IO.File.Copy(s, destfile, true);
}
-----------------------------------------------But when its run its occur error
Server Error in '/' Application.
The process cannot access the file 'I:\vasu\Project\test\error.png' because it is being used by another process.
CodeLine 48: System.IO.File.Copy(s, destfile, true);
Code
Line 48: System.IO.File.Copy(s, destfile, true);

Sunny SharmaRank #223 · 11.1K reputationPosted Sep 9, 2013, 9:02 PM EDT
try this:
-----------------------------------------------
Happy Coding :)
Cheers!
Vasu GadhiyaRank #7,540 · 239 reputationPosted Sep 9, 2013, 9:09 PM EDT