Could not find a part of the path while doing a File Copy
If at all possible, never give your code the opportunity to fail. If there's any possibility at all that you can prevent an error condition from being raised, do it. try{ if (!string.IsNullOrEmpty(FileName)) { string newPath = System.IO.Path.Combine(FilePath,...
If at all possible, never give your code the opportunity to fail. If there's any possibility at all that you can prevent an error condition from being raised, do it.
try
{
if (!string.IsNullOrEmpty(FileName))
{
string newPath = System.IO.Path.Combine(FilePath, FileName);
if (File.Exists(Path) && Path.ToLower() != newPath.ToLower())
{
File.Copy(Path, newPath, true);
}
}
}
catch (Exception ex)
{
// handle the exception as desired
}