Delete File C# with Example
string path = @"c:\path\to\file.txt";
While Delete does not throw exception if ﬁle doesn't exist, it will throw exception e.g. if speciﬁed path is invalid or
caller does not have the required permissions. You should always wrap calls to Delete inside try-catch block and
handle all expected exceptions. In case of possible race conditions, wrap logic inside lock statement.