Esempio n. 1
0
        /// <summary>
        /// Lädt die Vorgaben des aktuellen Anwenders.
        /// </summary>
        /// <returns>Die Vorgaben für diesen Anwender.</returns>
        public static PersistedUserProfile Load()
        {
            // Get the user profile directory
            var profileDir = new DirectoryInfo(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "DVBNETProfiles"));

            // Create
            profileDir.Create();

            // Get the file name
            var profile = new FileInfo(Path.Combine(profileDir.FullName, "UserProfile.dup"));

            // The new profile
            PersistedUserProfile settings;

            // Load or create
            if (!profile.Exists)
            {
                settings = new PersistedUserProfile();
            }
            else
            {
                using (var stream = new FileStream(profile.FullName, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    // Create serializer
                    var serializer = new XmlSerializer(typeof(PersistedUserProfile), ProfileNamespace);

                    // Process
                    settings = (PersistedUserProfile)serializer.Deserialize(stream);
                }
            }

            // Remember root
            settings.m_File = profile;

            // Report
            return(settings);
        }
Esempio n. 2
0
        /// <summary>
        /// Lädt die Vorgaben des aktuellen Anwenders.
        /// </summary>
        /// <returns>Die Vorgaben für diesen Anwender.</returns>
        public static PersistedUserProfile Load()
        {
            // Get the user profile directory
            var profileDir = new DirectoryInfo( Path.Combine( Environment.GetFolderPath( Environment.SpecialFolder.LocalApplicationData ), "DVBNETProfiles" ) );

            // Create
            profileDir.Create();

            // Get the file name
            var profile = new FileInfo( Path.Combine( profileDir.FullName, "UserProfile.dup" ) );

            // The new profile
            PersistedUserProfile settings;

            // Load or create
            if (!profile.Exists)
                settings = new PersistedUserProfile();
            else
                using (var stream = new FileStream( profile.FullName, FileMode.Open, FileAccess.Read, FileShare.Read ))
                {
                    // Create serializer
                    var serializer = new XmlSerializer( typeof( PersistedUserProfile ), ProfileNamespace );

                    // Process
                    settings = (PersistedUserProfile) serializer.Deserialize( stream );
                }

            // Remember root
            settings.m_File = profile;

            // Report
            return settings;
        }