Wednesday, February 17, 2010

Simple copy functionality in C#

public class SimpleFileCopy
{
public void CopyFile(string sourcePath, string targetPath, string folderPath)
{
try
{
if (!System.IO.Directory.Exists(folderPath))
{
System.IO.Directory.CreateDirectory(folderPath);
}
System.IO.File.Copy(sourcePath, targetPath, true);
}
catch (Exception ex)
{
}
}
}
#endregion

No comments: