private void LoadRecentProjects() { // Here we can present any recent projects we want // Maybe there are some canned ones in the Solution folder // Or there are some in a solution folder that is per user where they have read/write access //Assembly assembly = Assembly.GetExecutingAssembly(); //string location = assembly.Location; //DirectoryInfo dirInfo = Directory.GetParent(location); //string path = Path.Combine(dirInfo.FullName, "Projects"); const string path = @"C:\Configurations\Projects"; if (!Directory.Exists(path)) { return; } var projects = Directory.GetFiles(path, "*.aprx"); foreach (var project in projects) { var name = Path.GetFileNameWithoutExtension(project); var rp = new RecentProject { Name = name, Path = project }; _recentProjects.Add(rp); } }
internal RecentProject CreateProject(string name) { name = name.Trim(); name = name.TrimStart('_'); name = name.Replace("_", " "); //Assembly assembly = Assembly.GetExecutingAssembly(); //string location = assembly.Location; //DirectoryInfo dirInfo = Directory.GetParent(location); string path = @"c:\data\configurations\projects"; string subPath = Path.Combine(path, name); subPath = Path.ChangeExtension(subPath, ".aprx"); if (!File.Exists(subPath)) { var hasDefault = File.Exists(Path.Combine(path, "San Diego.aprx")); var msg = hasDefault ? "Using the default project 'San Diego.aprx' instead." : "The default project 'San Diego.aprx' doesn't exist either. Please add this project before running this demo."; MessageBox.Show($@"This project for {name} @ {subPath} cannot be found. {msg}"); if (!hasDefault) { return(null); } } if (!File.Exists(subPath)) { subPath = Path.Combine(path, "San Diego.aprx"); } RecentProject rp = new RecentProject { Name = name, Path = subPath }; return(rp); }