1

This is my code:

 var FinalPath = Path.Combine(DestPath, FinalFile);
 File.Copy(TempFile, FinalPath);

Destpath is "c:\Somepath\" and FinalFIle is "somefile.pdf" So FinalPath is: "c:\Somepath\somefile.pdf"

When Copy method is called i receive error (file already exists and throws an unwanted exception wich is not good).

How can i tell something like if(FinalPath.Exists = true)... ignore o continue ?

4
  • 7
    Does this answer your question? How to find out if a file exists in C# / .NET? Commented Mar 17, 2020 at 19:49
  • There are plenty of answers for this question. It should be closed as duplicate. Commented Mar 17, 2020 at 19:51
  • 1
    If overwriting the file is OK, there's an overload for that Commented Mar 17, 2020 at 19:51
  • Thanks, i did it. Commented Mar 17, 2020 at 20:27

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.