|
-
Oct 24th, 2011, 09:34 AM
#1
Thread Starter
New Member
[RESOLVED] ProgramData Folder (SpecialDirectories)
How can I write ProgramData path?
Example:
Code:
TextBox1.Text = My.Computer.FileSystem.SpecialDirectories.AllUsersApplicationData
Whit this code I'm getting "C:\ProgramData\Microsoft\ProgramData\1.0.0.0" (Win7), but I need something like this:
Vista/7 = C:\ProgramData
XP = C:\Documents and Settings\All Users\Application Data
Last edited by rossi_4656; Oct 24th, 2011 at 12:21 PM.
-
Oct 24th, 2011, 10:31 AM
#2
Lively Member
Re: ProgramData Folder (SpecialDirectories)
G'd Afternoon,
May be i don't understand your question. If you request the AllUsersApplicationData folder path, that's what you get. If you just want the paths above mentioned you may hard code them and check for the OS Name (WMI Library) or use the Microsoft.Win32 library to get the OS Version and set the paths accordingly. Something like this:
Code:
Imports Microsoft.Win32
Private sub SetPath() as string
Dim osInfo As OperatingSystem
Dim oVer As Version
'OS Version
'Version 5: XP and Sever 2003 family
'Version 6: Vista/Win7/Server 2008 Family
osInfo = Environment.OSVersion
oVer = osInfo.Version
Select Case CShort(oVer.Major)
Case 5
Return "C:\Documents and Settings\All Users\Application Data"
Case 6
Return "C:\ProgramData"
Case Else
Return string.empty
End Select
End Function
-
Oct 24th, 2011, 10:43 AM
#3
Re: ProgramData Folder (SpecialDirectories)
 Originally Posted by rossi_4656
How can I write ProgramData path?
Example:
Code:
TextBox1.Text = My.Computer.FileSystem.SpecialDirectories.AllUsersApplicationData
Whit this code I'm getting "C:\ProgramData\Microsoft\ProgramData\1.0.0.0" (Win7), but I need something like this:
Vista/7 = C:\ProgramData
XP = C:\Documents and Settings\All Users\Application Data
The path is different for each of the OS you have listed which is why a different folder is returned.
http://msdn.microsoft.com/en-us/libr...(v=vs.90).aspx
Make sure to read the Remarks section.
-
Oct 24th, 2011, 11:17 AM
#4
Addicted Member
Re: ProgramData Folder (SpecialDirectories)
vb Code:
Label1.Text = My.Computer.FileSystem.SpecialDirectories.AllUsersApplicationData
result is [w7 64] = C:\ProgramData\Microsoft\WindowsApplication1\1.0.0.0
using Environment...
vb Code:
Label2.Text = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)
result is [w7 64] = C:\ProgramData
vb Code:
Label2.Text = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)
result is [w7 64] = C:\Users\venice\AppData\Local
vb Code:
Label2.Text = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
result is [w7 64] = C:\Users\venice\AppData\Roaming
-
Oct 24th, 2011, 12:20 PM
#5
Thread Starter
New Member
Re: ProgramData Folder (SpecialDirectories)
 Originally Posted by medsont
vb Code:
Label1.Text = My.Computer.FileSystem.SpecialDirectories.AllUsersApplicationData
result is [w7 64] = C:\ProgramData\Microsoft\WindowsApplication1\1.0.0.0
using Environment...
vb Code:
Label2.Text = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)
result is [w7 64] = C:\ProgramData
vb Code:
Label2.Text = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)
result is [w7 64] = C:\Users\venice\AppData\Local
vb Code:
Label2.Text = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
result is [w7 64] = C:\Users\venice\AppData\Roaming
Thank you very much!
-
Oct 24th, 2011, 12:22 PM
#6
Addicted Member
Re: [RESOLVED] ProgramData Folder (SpecialDirectories)
u r so welcome.........
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|