How can I delete a file in C# e.g. C:\\test.txt, although apply the same kind of method like in batch files e.g.
C:\\test.txt
if exist \"C:\\test.txt\" dele
You could import the System.IO namespace using:
System.IO
using System.IO;
If the filepath represents the full path to the file, you can check its existence and delete it as follows:
if(File.Exists(filepath)) { try { File.Delete(filepath); } catch(Exception ex) { //Do something } }