How can I set the path of system.Environment.SpecialFolder.MyDocuments

H

Hans Meier

Hello

I would like to read out the path of mydocuments and then change it.

This is how i am trying to do it:

imports system.console
imports system.environment

Module Module1

Sub Main()

WriteLine(GetFolderPath(SpecialFolder.MyDocuments).ToString)
SetEnvironmentVariable(SpecialFolder.MyDocuments, _
"C:",EnvironmentVariableTarget.Machine)
SetEnvironmentVariable(SpecialFolder.MyDocuments, _
"C:", EnvironmentVariableTarget.User)
SetEnvironmentVariable(SpecialFolder.MyDocuments, _
"C:", EnvironmentVariableTarget.Process)

' now find out whether it changed
WriteLine(GetFolderPath(SpecialFolder.MyDocuments).ToString)

End Sub

End Module


But nothing changes. I get twice the same path.

What am i doing wrong? Can someone help me?

Thank you

Hans
 
F

Family Tree Mike

Hans Meier said:
Hello

I would like to read out the path of mydocuments and then change it.

This is how i am trying to do it:

Well that's an interesting try. What you ended up doing is creating an
evironment variable with the name something like "c:\documents and
settings\users\fred\My Documents" to be equal to the path you wanted.

..Net does not provide a SetFolderPath(specialfolder) routine. You will
probably need to change a registry key to change the folder location. I
found a reference that says this is the key

HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell
Folders\Personal
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top