static void EnsurePath(string path) { var dir = Path.GetDirectoryName(path); if(!Directory.Exists(dir)) Directory.CreateDirectory(dir); if(File.Exists(path)) File.Delete(path); }