c#: Dial a modem using dotras

584 Views Asked by At

im using huawei e359

Hello im creating a simple program. where my code will connect the 3g modem to the internet. because a part of my program need to access the internet. i did some search how to do this using c#

this is my code for adding entry

string deviceName = null;
                path = RasPhoneBook.GetPhoneBookPath(RasPhoneBookType.User);
                using (RasPhoneBook pbk = new RasPhoneBook())
                {
                    pbk.Open(path);
                    foreach (var item in RasDevice.GetDevices())
                    {
                        if (item.DeviceType.ToString().ToLower() == "modem")
                        {
                            deviceName = item.Name;
                        }
                    }
                    RasDevice device = RasDevice.GetDevices().Where(o => o.Name == deviceName && o.DeviceType == RasDeviceType.Modem).First();
                    if (!RasEntry.Exists("Your Entry", path))
                    {
                        RasEntry entry = RasEntry.CreateDialUpEntry("Your Entry", "+00000000000", device);
                        pbk.Entries.Add(entry);
                    }
                }

and this is the code for dialing the device

using (RasDialer dialer = new RasDialer())
                {
                    dialer.EntryName = "Your Entry";
                    dialer.PhoneBookPath = path;
                    dialer.AllowUseStoredCredentials = true;
                    dialer.Dial();
                }

this is the error, it prompts when i dial the device

The remote computer did not respond. To make sure that the server can be reached, ping the remote computer.
0

There are 0 best solutions below