如何访问.URL文件的URL和书签标题? [英] How to access URL and bookmark title in .URL files?

查看:1085
本文介绍了如何访问.URL文件的URL和书签标题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用.NET 2.0的Visual Studio 2005的C#。

在code以下获取从目录中的IE收藏夹(书签),它包含书签的.url文件的文件名

示例

../用户/收藏/ blah.url

但我真正想要的是文件里的书签网址。

在查看文件的属性,在Web文档选项卡,它显示文件名和URL。

我如何从C#访问它?

code

  //在$ C $低于刚刚获得字符串,如C...... /用户/收藏/ blah.url
 //调用该方法的文件夹路径:
 //GetFavoriteFiles(Environment.GetFolderPath(Environment.SpecialFolder.Favorites));


私人列表<字符串> favFiles =新的名单,其中,字符串>();

私人无效GetFavoriteFiles(字符串的文件夹)
{
    的String []的收藏= Directory.GetFiles(文件夹);
    favFiles.AddRange(的收藏);
    的String []文件夹= Directory.GetDirectories(文件夹);

    如果(文件夹!= NULL)
    {
       的foreach(字符串S在文件夹)
       {
          GetFavoriteFiles(多个);
       }
    }
}
 

解决方案

我在记事本++开了一个的.url ,这是我发现了什么。请注意,这是在IE8中产生。 此页面有详细介绍到的格式的.url (Internet快捷方式)文件。

  [默认]
的baseUrl = HTTP://www.google.com.au/
[{000214A0-0000-0000-C000-000000000046}]
Prop3 = 19,2
[InternetShortcut]
URL = HTTP://www.google.com.au/
IDLIST =
ICONFILE = HTTP://www.google.com.au/favicon.ico
IconIndex = 1
 

您应该能够解析这个容易使用的基本的StreamReader IO。

I'm using .NET 2.0 Visual Studio 2005 C#.

The code below gets file name of the IE favorites (bookmark) from the directory that contains bookmarked .url files

Example

../users/favorites/blah.url

But what I really want is the bookmarked URL inside of that file.

When check the file property, in the web document tab, it shows filename and URL.

How can I access it from C#?

CODE

 //the code below just get String like "..../users/favorites/blah.url"
 //call the method with the folder path: 
 //GetFavoriteFiles(Environment.GetFolderPath(Environment.SpecialFolder.Favorites));


private List<String> favFiles = new List<String>();

private void GetFavoriteFiles(String folder)
{
    String[] favs = Directory.GetFiles(folder);
    favFiles.AddRange(favs);
    String[] folders = Directory.GetDirectories(folder);

    if(folders != null)
    {
       foreach(String s in folders)
       {
          GetFavoriteFiles(s);
       }
    }
}

解决方案

I opened a .url in Notepad++ and this is what I found. Note, this was generated in IE8. This page has a detailed look into the format of the .url (internet shortcut) file.

[DEFAULT]
BASEURL=http://www.google.com.au/
[{000214A0-0000-0000-C000-000000000046}]
Prop3=19,2
[InternetShortcut]
URL=http://www.google.com.au/
IDList=
IconFile=http://www.google.com.au/favicon.ico
IconIndex=1

You should be able to parse this easily using basic StreamReader IO.

这篇关于如何访问.URL文件的URL和书签标题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆