Question about System.Enviroment.GetFolder()

  • Thread starter Thread starter Anthony Papillion
  • Start date Start date
A

Anthony Papillion

So I'm trying to build a path variable that points to a longer path so I
don't have to keep typing out the entire thing. I discovered the
GetSpecialFolder() method and I'm trying to use it like this:

Friend AppDataPath as String =
System.Enviroment.GetFolderPath(Enviroment.GetSpecialFolder.ApplicationData())
& "\myAppName"

My thought is, instead of typing the whole path to the users ApplicationData
folder, I could simply substitute the AppDataPath variable there. However,
the compiler is complaining that I can't convert an integer to a string or
something like that and I can't seem to fix it.

So I displayed the path in a messagbox like this:

MsgBox(AppDataPath)

and I get something like "26\myAppName" instead of any real path.

WTF? What is going on here?
Someone at the MSDN forums told me that I can append my own text to the
returned string but I can't see WHY that would be. Is that true? If it is,
is there a workaround?


Thanks for the help everyone.

Anthony
 
Anthony said:
So I'm trying to build a path variable that points to a longer path so I
don't have to keep typing out the entire thing. I discovered the
GetSpecialFolder() method and I'm trying to use it like this:

Friend AppDataPath as String =
System.Enviroment.GetFolderPath(Enviroment.GetSpecialFolder.ApplicationData())
& "\myAppName"

My thought is, instead of typing the whole path to the users ApplicationData
folder, I could simply substitute the AppDataPath variable there. However,
the compiler is complaining that I can't convert an integer to a string or
something like that and I can't seem to fix it.

So I displayed the path in a messagbox like this:

MsgBox(AppDataPath)

and I get something like "26\myAppName" instead of any real path.

WTF? What is going on here?
Someone at the MSDN forums told me that I can append my own text to the
returned string but I can't see WHY that would be. Is that true? If it is,
is there a workaround?


Thanks for the help everyone.

I don't get it. The line above creates that String? Or which line does it?
The code above is not compilable anyway. What's your _real_ code?

Dim AppDataPath As String = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\myAppName"

And it returns what I expect. No 26 in it.

side note: IO.Path.Combine is nice.
 
So I'm trying to build a path variable that points to a longer path so I
don't have to keep typing out the entire thing. I discovered the
GetSpecialFolder() method and I'm trying to use it like this:

Friend AppDataPath as String =
System.Enviroment.GetFolderPath(Enviroment.GetSpecialFolder.ApplicationData())
& "\myAppName"

My thought is, instead of typing the whole path to the users
ApplicationData folder, I could simply substitute the AppDataPath
variable there. However, the compiler is complaining that I can't
convert an integer to a string or something like that and I can't seem
to fix it.

So I displayed the path in a messagbox like this:

MsgBox(AppDataPath)

and I get something like "26\myAppName" instead of any real path.

WTF? What is going on here?
Someone at the MSDN forums told me that I can append my own text to the
returned string but I can't see WHY that would be. Is that true? If it
is, is there a workaround?


Thanks for the help everyone.

Anthony

First, I highly recommend using Path.Combine(part1, part2) to build full
paths, rather than part1 & part2. You won't need to eorry about missing
or extra slashes at the joints.

As Armin alluded to, your code which produced 26\myAppName is not shown.

Likely, what you did was:
Environment.GetSpecialFolder.ApplicationData & "myAppName".

GetSpecialFolder is an enumeration which equates to an int in your case.
This is why the Environment.GetFolderPath is necessary, to get the
actual string for the enumeration value.
 
Hallo Anthonhy,

It works seldom with so many typos and using a method instead of the enum

Friend AppDataPath As String =
System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData)

Success

Cor
 
Back
Top