C# url 用 浏览器打开、C#获取浏览器的url
static void Main(string[] args) { string file = @"C:UsersHeroDesktopSiteWhitelist.tsv"; string[] lines = System.IO.File.ReadAllLines(file); foreach (var url in lines) { var startInfo = new ProcessStartInfo("firefox.exe", url); Process.Start(startInfo); string getUrl = GetBrowserURL("FireFox"); Thread.Sleep(10000); File.WriteAllText(@"C:UsersHeroDesktopSaveSiteWhitelist.txt", getUrl + Environment.NewLine + File.ReadAllTex (@"C:UsersHeroDesktopSaveSiteWhitelist.txt")); } Console.ReadKey(); } public static string GetBrowserURL(string browser) { try { DdeClient dde = new DdeClient(browser, "WWW_GetWindowInfo"); dde.Connect(); string url = dde.Request("URL", int.MaxValue); string[] text = url.Split(new string[] { "","" }, StringSplitOptions.RemoveEmptyEntries); dde.Disconnect(); return text[0].Substring(1); } catch { return null; } }