2 Simple Questions
-
I got 2 quick questions: 1> System.Diagnostics.Process.Start("Explorer.exe", "%USERPROFILE%\My Documents\") returns folder doesn't exist because I have my documents in there, but I need to goto my documents, what should I do? 2> How do you set a global variable in .net that is accessable across multiple forms. Like Dim blah as Global? Thanks...
-
I got 2 quick questions: 1> System.Diagnostics.Process.Start("Explorer.exe", "%USERPROFILE%\My Documents\") returns folder doesn't exist because I have my documents in there, but I need to goto my documents, what should I do? 2> How do you set a global variable in .net that is accessable across multiple forms. Like Dim blah as Global? Thanks...
arunforce wrote:
%USERPROFILE%
You can't do this, you need to look up the path and pass the full path in.
arunforce wrote:
How do you set a global variable in .net that is accessable across multiple forms. Like Dim blah as Global?
The only way is to have a class that holds it, and make it public and static. Consider making it a property, at least, and consider overall if it REALLY needs to be public. If you need to share stuff between two forms, a delegate is a better way to do it.
Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
-
arunforce wrote:
%USERPROFILE%
You can't do this, you need to look up the path and pass the full path in.
arunforce wrote:
How do you set a global variable in .net that is accessable across multiple forms. Like Dim blah as Global?
The only way is to have a class that holds it, and make it public and static. Consider making it a property, at least, and consider overall if it REALLY needs to be public. If you need to share stuff between two forms, a delegate is a better way to do it.
Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
-
Then how do people do things such as that, with programs? It opens their my documents, I can do %userprofile% fine, I just can't attach my documents to the end. I don't think you know much about that. And, how would I go about doing a class in VB.NET?
The Environment.SpecialFolder enum allows you to ask for the path to folders such as the userprofile.
arunforce wrote:
And, how would I go about doing a class in VB.NET?
There is no way to write code in VB.NET outside of a class. Do you know what a class is ? If not, you need to take a step back and learn some basics.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog