Created
August 1, 2012 13:10
-
-
Save nissuk/3226719 to your computer and use it in GitHub Desktop.
C#: Windowsで.weblocを開く
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.IO; | |
using System.Xml.Linq; | |
using System.Xml.XPath; | |
using System.Diagnostics; | |
namespace webloc | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
if (args.Length <= 0) return; | |
var filename = args[0]; | |
if (Path.GetExtension(filename) != ".webloc") return; | |
var webloc = XDocument.Load(filename); | |
//var urlNode = webloc.XPathSelectElements("/plist/dict/string[preceding-sibling::key/text()=\"URL\"]").First(); | |
var urlNode = webloc.Descendants("string").First(); | |
if (urlNode == null) return; | |
Process.Start(urlNode.Value); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment