public void Save (ProfileEntry[] options) { if (!Directory.Exists (Path.GetDirectoryName (_filePath))) Directory.CreateDirectory (Path.GetDirectoryName (_filePath)); File.WriteAllText (_filePath, Serializer<ProfileEntry[]>.Serialize (options)); }
public static string GetOrCreateConfigFileName (string applicationDataDirectory, string profileName) { var profileDataAccess = new ProfileListDataAccess (Path.Combine (applicationDataDirectory, "profiles.xml")); var profiles = profileDataAccess.Load(); var profile = profiles.FirstOrDefault (p => p.ProfileName.Equals (profileName, StringComparison.OrdinalIgnoreCase)); if (profile == null) { profile = new ProfileEntry() { ProfileName = profileName, ConfigFileName = string.Format ("options_{0}.xml", Guid.NewGuid()) }; profiles = profiles.Union (new[] { profile }).ToArray(); profileDataAccess.Save (profiles); } return profile.ConfigFileName; }