public string GetFilePath(Wallpaper wallpaper, string filename, string location = "") { var dir = AppDomain.CurrentDomain.BaseDirectory; location = string.IsNullOrEmpty(location) ? FolderPath : location; if (string.IsNullOrEmpty(location)) return Path.Combine(dir, string.Format(@"{0}.{1}", filename, wallpaper.Extension.ToString().ToLower())); return Path.Combine(dir, string.Format(@"{0}\{1}.{2}", location, filename, wallpaper.Extension.ToString().ToLower())); }
// if the file exists already, append (n) to the end to make it unique string GetValidFileName(string location, Wallpaper wallpaper) { string name = Provider.GetFileName(wallpaper); string newName = name; int i = 1; while (File.Exists(GetFilePath(wallpaper, newName, location))) { newName = name + " (" + ++i + ")"; } return newName; }
public string GetFilePath(Wallpaper wallpaper) { return GetFilePath(wallpaper, Provider.GetFileName(wallpaper)); }
public string GetFileName(Wallpaper wp) { return string.Format(FileNameFormat, wp.Id.ToString()); }