Updated on Kisan Patel
To get the current location of device, you have to add reference to System.Device
DLL.
GeoCoordinateWatcher
class supplies location data that is based on latitude and longitude coordinates.
The following program shows how to use a GeoCoordinateWatcher
class to obtain current location:
using System; using System.Device.Location; namespace WhereAmI { class Program { static void Main(string[] args) { Console.WriteLine("Starting GeoCoordinate Watcher..."); // 2. Use the GeoCoordinate Watcher var watcher = new GeoCoordinateWatcher(); watcher.StatusChanged += (s, e) => { Console.WriteLine($"GeoCoordinateWatcher:StatusChanged:{e.Status}"); }; watcher.PositionChanged += (s, e) => { Console.WriteLine($"GeoCoordinateWatcher:PositionChanged:{e.Position.Location}"); }; watcher.MovementThreshold = 100; watcher.Start(); Console.WriteLine("Press any key to exit..."); Console.ReadKey(); } } }