File Manipulations: Simple File Copy
Overview
I made some simple codes I did not get to use at work to copy one file from source to destination. It's a little crude around the edges and it needs a little more work.
Code Inspection
Check out the following codes:
string filename = "XXX.XML";
StringBuilder srcPath = new StringBuilder(testContext.TestDeploymentDir);
StringBuilder destPath = new StringBuilder(testContext.TestDeploymentDir);
if(!File.Exists(destPath.ToString() + "\\" + filename))
{
srcPath.Append("\\..\\..\\..\\..\\XXX\\YYY\\Database\\XXXXX");
srcPath.AppendFormat("\\{0}", filename);
destPath.AppendFormat("\\{0}", filename);
try
{
File.Copy(srcPath.ToString(), destPath.ToString());
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}