Beispiel #1
0
        /// <summary>
        /// Opens the phone book.
        /// </summary>
        /// <param name="phoneBookPath">The path (including filename) of a phone book.</param>
        /// <remarks>This method opens an existing phone book or creates a new phone book if the file does not already exist.</remarks>
        /// <exception cref="System.ArgumentException"><paramref name="phoneBookPath"/> is an empty string or null reference (<b>Nothing</b> in Visual Basic).</exception>
        /// <exception cref="System.UnauthorizedAccessException">The caller does not have the required permission to perform the action requested.</exception>
        public void Open(string phoneBookPath)
        {
            if (string.IsNullOrEmpty(phoneBookPath))
            {
                ThrowHelper.ThrowArgumentException("phoneBookPath", Resources.Argument_StringCannotBeNullOrEmpty);
            }

            FileInfo file = new FileInfo(phoneBookPath);

            if (string.IsNullOrEmpty(file.Name))
            {
                ThrowHelper.ThrowArgumentException("phoneBookPath", Resources.Argument_InvalidFileName);
            }

            RasPhoneBookType phoneBookType = RasPhoneBookType.Custom;

            if (string.Equals(phoneBookPath, RasPhoneBook.GetPhoneBookPath(RasPhoneBookType.AllUsers), StringComparison.CurrentCultureIgnoreCase))
            {
                phoneBookType = RasPhoneBookType.AllUsers;
            }
            else if (string.Equals(phoneBookPath, RasPhoneBook.GetPhoneBookPath(RasPhoneBookType.User), StringComparison.CurrentCultureIgnoreCase))
            {
                phoneBookType = RasPhoneBookType.User;
            }

            this.Path          = file.FullName;
            this.PhoneBookType = phoneBookType;

            // Setup the watcher used to monitor the file for changes, and attempt to load the entries.
            this.SetupFileWatcher(file);
            this.Entries.Load();

            this.opened = true;
        }
Beispiel #2
0
        public void Open(bool openUserPhoneBook)
        {
            RasPhoneBookType phoneBookType = RasPhoneBookType.AllUsers;

            if (openUserPhoneBook)
            {
                phoneBookType = RasPhoneBookType.User;
            }

            this.Open(RasPhoneBook.GetPhoneBookPath(phoneBookType));
            this.PhoneBookType = phoneBookType;
        }