Vorrei testare una stringa contenente un percorso a un file per l'esistenza di quel file (qualcosa come il -e
test in Perl o os.path.exists()
in Python) in C #.
Vorrei testare una stringa contenente un percorso a un file per l'esistenza di quel file (qualcosa come il -e
test in Perl o os.path.exists()
in Python) in C #.
Risposte:
Uso:
File.Exists(path)
MSDN: http://msdn.microsoft.com/en-us/library/system.io.file.exists.aspx
Modifica: in System.IO
using System.IO;
if (File.Exists(path))
{
Console.WriteLine("file exists");
}