日期:2014-05-18  浏览次数:20571 次

ASP.NET如何按标签读取浏览器收藏夹的htm文件啊?
如何按照收藏夹htm文件中的标签读取标签内的信息呢?
例如:
<TITLE>Bookmarks</TITLE>
<H1>Bookmarks</H1>
<DL><p>
  <DT><A HREF="http://www.baidu.com/" ADD_DATE="0" LAST_VISIT="0" LAST_MODIFIED="1273848075">百度一下,你就知道</A>

------解决方案--------------------
<input type=button value=导出收藏夹 onclick="window.external.ImportExportFavorites(false,'http://localhost');">

DirectoryInfo favfolder = new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.Favorites));
FileSystemInfo[] myFileSystemInfo = favfolder.GetFileSystemInfos();

private void GetDir(FileSystemInfo[] myFavDir)
{
string myStr = "";
string myUrl = "";
string myDesc = "";
foreach (FileSystemInfo filesysteminfo in myFileSystemInfo)
{
if (filesysteminfo.GetType() == typeof(DirectoryInfo))
{

DirectoryInfo childfile = (DirectoryInfo)filesysteminfo;
GetDir(childfile.GetFileSystemInfos())  
}

else if (filesysteminfo.GetType() == typeof(FileInfo))
{
string fitler = ".url";
if (filesysteminfo.FullName.ToLower().EndsWith(fitler.ToLower()))
{
using (StreamReader sr = new StreamReader(filesysteminfo.FullName, Encoding.Default))
{
myStr = sr.ReadLine();
while (myStr != null)
{

if (myStr.ToLower().StartsWith(URLPrefix))
{
myUrl = myStr.Substring(URLPrefix.Length);

}
else if (myStr.ToLower().StartsWith(DescriptionPrefix))
{
myDesc = myStr.Substring(DescriptionPrefix.Length);
}
myStr = sr.ReadLine();
}
}
}
}
}
}