How to get file names from the directory, not the entire path
Try GetFileName()
method:
Path.GetFileName(filename);
System.IO.Path
is your friend here:
var filenames = from fullFilename
in Directory.EnumerateFiles(targetdirectory,"backup-*.zip")
select Path.GetFileName(fullFilename);
foreach (string filename in filenames)
{
// ...
}
You could use the GetFileName method to extract only the filename without a path:
string filenameWithoutPath = Path.GetFileName(filename);