Wednesday, August 5, 2009

How to Copy a file in C#

Here i am showing how to copy a file source to destination filepath in C#. The file with the filepath 'databasePath' will copy to the destination filepath 'ryanDataPath'
private void CopyDBToCommonFile(string databasePath, string ryanDataPath)
{
FileInfo fi = new FileInfo(ryanDataPath + "\\DB\\SmartChart.mdb"); \\Destination file path
if (!fi.Exists)
{
FileInfo fc = new FileInfo(databasePath); \\Source file path
fc.CopyTo(fi.FullName, true);
}
}

No comments:

Post a Comment