Subject: extract URL from Favorites (.URL Files)
Posted By: PhilHawks Post Date: 10/26/2004 9:26:11 AM
Hello,

I am very new to VB.NET (And programming in general for that matter) and for a first project I am building a small app which requires extracting the Name, URL and IconFile from all the IE Favorites in the folder.  I have searched the net endlessly, so far coming up with one or 2 methods but no real way of doing what I need to.

The 2 methods mentioned were either using CSID_InternetShortcut (But this looks VERY difficult, using lots of COMs etc) or simply opening each .URL file and extracting the text I need from inside it.

The contents of a typical .URL file are:

[DEFAULT]
BASEURL=http://www.google.com/
[InternetShortcut]
URL=http://www.google.com/
Modified=D017B822654EC40139
IconFile=http://www.google.com/favicon.ico
IconIndex=1


I assume that no matter what I do I will need to enumerate the whole folder.

Can anyone point me in the right direction please?
Reply By: PhilHawks Reply Date: 10/29/2004 10:17:18 PM
o.k...  I have gone down the root of opening each file for its contents.  I can get the information I need from the file contents and file name.

All I need to do now is enumerate through the folder and subfolders.

I found a piece of C# code which seems to do the trick but can't figure out how to do the same thing in VB.


DirectoryInfo di = new DirectoryInfo(System.Environment.GetFolderPath(Environment.SpecialFolder.Favorites));
EnumerateFavorites(di);      

private void EnumerateFavorites(DirectoryInfo dii)
{
    tv.Nodes.Add(dii.FullName);
   int i = tv.Nodes.Count-1;
   foreach(DirectoryInfo dI in dii.GetDirectories())
   {            
       EnumerateFavorites(dI);
   }

   foreach(FileInfo fi in dii.GetFiles())
   {
           tv.Nodes[i].Nodes.Add(fi.FullName);
   }
}


I am getting stuck on the part where the array is prepared.


    tv.Nodes.Add(dii.FullName);
   int i = tv.Nodes.Count-1;


Can anyone tell me how to achieve this in VB.NET?

Thanks all!
Reply By: anubhav.kumar Reply Date: 11/2/2004 3:35:30 AM
The code in which you are stuck is
*************************************
 tv.Nodes.Add(dii.FullName);
   int i = tv.Nodes.Count-1;
**************************************

Please note carefully that 'tv' is actually a tree view.
To use an array instead, you can write

Dim MyArray() as string
Dim i as integer

foreach(FileInfo fi in dii.GetFiles())
   {
       i=i+1    
       MyArray(i)=fi.FullName;
   }





Anubhav Kumar

Go to topic 21320

Return to index page 726
Return to index page 725
Return to index page 724
Return to index page 723
Return to index page 722
Return to index page 721
Return to index page 720
Return to index page 719
Return to index page 718
Return to index page 717