I want to have Buttons in a VB Form navigating to places like,My Documents, Network Places, My Pictures etc.
Does anone know code for me to be able to do this...
Thanks
I want to have Buttons in a VB Form navigating to places like,My Documents, Network Places, My Pictures etc.
Does anone know code for me to be able to do this...
Thanks
I want a button that will navigate to the My Document folder when pressed
DevDiver
you shouldnt need to access the registry. You will have problems eventually such as security issues. Nor should you need to create a batch file :-)
Best thing to do is spin up a process of the MyDocuments using the Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
the SpecialFolder enumerator gives you a list of standard user folders you can access. This would be the best way
Rach M
Drksrvnt
Ed C
JDPeckham
I am working in VB (VS2005) and WM5 pocketPC
Imports System
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Console.WriteLine()
Console.WriteLine("GetFolderPath: {0}", Environment.GetFolderPath(Environment.SpecialFolder.Personal))
End Sub
End Class
When I press the button nothing happens. I know I am doing something wrong. Also If I try using the work MyDocuments in place of Personal I get an error.
DeadDante
tonalt
Why do you believe something is wrong It appears you forgot to describe what you expect this code to do and what it actually does.
To get help faster, see this, items 7, 10, 12, and 17.
GazCoder
' Sample for the Environment.GetFolderPath method Imports System Class Sample Public Shared Sub Main() Console.WriteLine() Console.WriteLine("GetFolderPath: {0}", Environment.GetFolderPath(Environment.SpecialFolder.System)) End Sub 'Main End Class 'Sample ' 'This example produces the following results: ' 'GetFolderPath: C:\WINNT\System32 'Pr09aN1g0d
* you can make it create a batch file (ends with .bat) with a command text
Dim filename1 As Object
filename1 = 'save path' & 'filename'
FileOpen(1, filename1, OpenMode.Output)
Print(1, 'commandtext')
FileClose(1)
* heres the command to open documents :
start "%userprofile%\My Documents"
* then , make then program start it :
System.Diagnostics.Process.Start(batch file path)
* if you want to have it work with all windows languages, make ur program read data on registry values in this subkey :
Hkey_current_user\software\Microsoft\Windows\CurrentVersion\explorer\shellfolders
you will find loads of path for currentuser there
Zulbaric
That code could not possibly do that. At best it would print out some stuff to console if you have it or do exactly nothing if you don't have console (which is the case on most Windows Mobile devices).
Depending on what do you mean by “take you to the folder” you should use something else, e.g. launch a file explorer process via System.Diagnostics.Process class or open file dialog using System.Windows.Forms.SaveFileDialog/OpenFileDialog.
Just out of curiosity: how you come to the conclusion Console.WriteLine would “take you to the folder” and not just write line to the console Is MSDN documentation confusing and suggests something like this
Michael Herman - Parallelspace
Srdjan
what error do you get
thread moved to the correct forum
Asif Hameed
I am not sure whats wrong with the code
can anyone please help
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'GetFolderPath: My Documents
Console.WriteLine()
Console.WriteLine("GetFolderPath: {0}", Environment.GetFolderPath(Environment.SpecialFolder.Personal))
End Sub
End Class
Stephan Smetsers