Skip to content

Instantly share code, notes, and snippets.

@nissuk
Created August 1, 2012 13:10
Show Gist options
  • Save nissuk/3226719 to your computer and use it in GitHub Desktop.
Save nissuk/3226719 to your computer and use it in GitHub Desktop.
C#: Windowsで.weblocを開く
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