1
Vote

The system could not update the phone booke file

description

hey,I write down a multi-threads connect vpn program using c#.When i debug this program,it's give me this error "RasException was caught:The system could not update the phone book file".How to fix it?

This code is the main code to handle rasphonebook.
        private VPNAssist() { }

        static string Path = RasPhoneBook.GetPhoneBookPath(RasPhoneBookType.User);
        static readonly object RPBObj = new object();
        static readonly object ProObj = new object();

        public static bool RPBHandle(string vpnName, RasEntry entry, bool backValue)
        {
            bool rv = false;
            System.Threading.Monitor.Enter(RPBObj);
            using (RasPhoneBook RPB = new RasPhoneBook())
            {
                RPB.Open(Path);
                if (backValue)
                    rv = RPB.Entries.Contains(vpnName);
                else
                {
                    if (!string.IsNullOrEmpty(vpnName))
                        RPB.Entries.Remove(vpnName);
                    else if (entry != null)
                        RPB.Entries.Add(entry);
                    rv = false;
                }
            }
            System.Threading.Monitor.Exit(RPBObj);
            return rv;
        }

comments