public static string selectProgramAppDataFolder(string filename) { /** * 1. If filename exists in user folder (C:\Users\[user name]\AppData\Local\[Random Photo Screensaver]\filename) return full path * 2. Otherwise return full path to program data folder (C:\ProgramData\[Random Photo Screensaver]\filename) **/ //Console.WriteLine("findOrInitInDataFolder: " + filename); string fullPath; fullPath = Path.Combine(Constants.getLocalAppDataFolder(), filename); /* 1 */ if (!File.Exists(fullPath)) { /* 2 */ fullPath = Path.Combine(Constants.getProgramDataFolder(), filename); } return(fullPath); }
public static string getDataFolder(string filename) { /** * 1. development folder * 2. user folder (C:\Users\[user name]\AppData\Local\[Random Photo Screensaver]) * 3. program data folder (C:\ProgramData\[Random Photo Screensaver]) * 4. executable folder **/ //Console.WriteLine("getDataFolder: " + filename); string notFound = ""; string fullPath; /* 1 */ fullPath = Path.Combine(Application.StartupPath, Constants.devDataFolder, filename); /* 2 */ if (!File.Exists(fullPath)) { notFound += fullPath + "\r\n"; fullPath = Path.Combine(Constants.getLocalAppDataFolder(), Constants.DataFolder, filename); /* 3 */ if (!File.Exists(fullPath)) { notFound += fullPath + "\r\n"; fullPath = Path.Combine(Constants.getProgramDataFolder(), Constants.DataFolder, filename); /* 4 */ if (!File.Exists(fullPath)) { notFound += fullPath + "\r\n"; fullPath = Path.Combine(Application.StartupPath, Constants.DataFolder, filename); requireFile(fullPath); } } } return(fullPath); }
public static string getUpdateFolder() { return(Path.Combine(Constants.getLocalAppDataFolder(), Constants.DownloadFolder)); }