Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > VB.NET 2002/2003 Basics
| Search | Today's Posts | Mark Forums Read
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old October 26th, 2004, 09:26 AM
Registered User
 
Join Date: Oct 2004
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default extract URL from Favorites (.URL Files)

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:
Code:
[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?
  #2 (permalink)  
Old October 29th, 2004, 10:17 PM
Registered User
 
Join Date: Oct 2004
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.

Code:
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.

Code:
    tv.Nodes.Add(dii.FullName);
   int i = tv.Nodes.Count-1;
Can anyone tell me how to achieve this in VB.NET?

Thanks all!
  #3 (permalink)  
Old November 2nd, 2004, 04:35 AM
Friend of Wrox
Points: 410, Level: 7
Points: 410, Level: 7 Points: 410, Level: 7 Points: 410, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2004
Location: New Delhi, India.
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anubhav.kumar
Default

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
URL Redirect based on given URL somnath.kartic VS.NET 2002/2003 1 August 2nd, 2012 08:21 AM
URL rewriting with URL forwarding mtabyana BOOK: Professional Search Engine Optimization with PHP: A Dev's Guide to SEO ISBN: 978-0-470-10092-9 0 October 22nd, 2007 08:22 AM
URL MunishBhatia ASP.NET 2.0 Professional 4 May 11th, 2007 10:31 AM
how to get the URL js_pandey Beginning PHP 2 July 8th, 2005 08:08 AM
URL scisoft HTML Code Clinic 2 April 9th, 2004 07:29 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.