Navigate to a local folder using webbrowser.

woodzee

New member
Joined
Oct 20, 2009
Messages
2
Programming Experience
Beginner
Hi all,

I'm guessing there is a really simple answer to this but i've spent the best part of 2 days trying to get it to work and cannot figure it out.

Basically, I want is the webbrowser to point to a local folder on a machine. A different one depending on who is logged on. The code I have so far is as follows.

VB.NET:
Imports System.IO

Public Class frmFav

    Private Sub frmFav_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim username As String
        Dim directoryname As String
        
        username = Environment.UserName
        directoryname = "C:\Documents and Settings\" & username & "\Local Settings\Application Data\OppsApp"
        Label1.Text = directoryname
        
        FavProgs.Navigate(New Uri(directoryname))

   
        End Sub

End Class

I cannot get the URL value of the webbrowser (FavProgs) to take the value of directoryname. If I set the URL value in the properties for FavProgs it does what I want it to do perfectly.

Any help would be greatly appreciated. I have bald spots now!!!

Thanks,

Chris
 
Navigating to any valid folder with your code works for me, have you verified that the target path exists?
A better option to get such dynamic paths is:
VB.NET:
Dim path As String = Application.UserAppDataPath
 
Hi,

Thanks for the response. And that's a wicked tip. Will give it a go.

It was sooooo anoyingly simple in the end. Because I was using A remote desktop program to my home PC from work, and the time of day that it was the network was very slow. Somehow I had managed to change one of the properties without knowing it.

I removed the WebBrowser and added a new one, and it worked straight away. Very frustrating, I had spend hours trawling the net to find out why it was not working.

Oh well, live and learn.
 
Back
Top