I've noticed that when I tried to set a string variable to the folderBrowserDialog.SelectedPath property it does not work. Can someone please explain why that is and is there a way around this? I don't want to have to keep writing folderBrowserDialog.SelectedPath every time I need to use it. Thanks in advance for your reply.
I've noticed that when I tried to set a string variable to the folderBrowserDialog.SelectedPath property it does not work.
"Works on my machine".
Perhaps it'd help if you posted your code? The only way the property (which is a string, an can be assigned to a string-variable) is when the object that owns the property is not yet created. You'd get a refernce-exception.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
The "UnauthorizedAccessException was unhandled" exception was thrown and I get the error message "Access to the path 'C:\MyTestFile' is denied" when I run the code above. It works fine if I use folderBrowserDialog1.SelectedPath in place of myFolderPath.
You can't set string myFolderPath = folderBrowserDialog1.SelectedPath; until after the dialog has returned!
The string there before the call is not modified in place by the dialog.
It is replaced by the dialog. myFolderPath just has the wrong value.
Without seeing the result of the string concatentation you're using inside the parenthsis in the CreateText call, it's impossible to say for sure.
But, if the result is actually a valid path and you're trying to create a file in the root of C: on Vista or Win7, you'll get that error because normal Users cannot create files in the root of C:. You can make folder, not files.
On top of that, why are you calling ToString() on txtFileName.Text?? The .Text property returns a string, so the call to ToString() is a bit redundant.
Thank you everyone for responding. After reading your posts and reexamining my code, I realized that I did make two noob's mistakes. I've fixed the errors and everything works fine. I learned some valuable lessons today and that was the intention of the current project I'm working on. Thanks again for replying.
Last Visit: 31-Dec-99 18:00 Last Update: 27-Aug-14 16:40