Gets a path for storing the current user's application data.
' Usage Dim value As String = My.Computer.FileSystem.SpecialDirectories.CurrentUserApplicationData ' Declaration Public ReadOnly Property CurrentUserApplicationData As String
String.
The following condition may cause an exception:
The path is empty, usually because the operating system does not support the directory (DirectoryNotFoundException).
The My.Computer.FileSystem.SpecialDirectories Object contains paths to commonly referenced directories.
If the path does not exist, it is created with the following format: BasePath\CompanyName\ProductName\Version
A typical BasePath in Windows XP is C:\Documents and Settings\username\Application Data. The CompanyName, ProductName, and Version can be obtained from the My.Application.Info.CompanyName, My.Application.Info.ProductName, and My.Application.Info.Version properties.
If the Company and Product names are not specified in the Assembly Information dialog box, the CompanyName\ProductName in the path are replaced with the assembly name. For more information on setting assembly information names, see How to: Specify Assembly Information (Visual Basic, C#).
Data stored in this path is part of a user profile that is enabled for roaming. A roaming user works on more than one computer in a network. The user profile for a roaming user is kept on a server on the network and is loaded onto a system when the user logs on. For a user profile to be eligible for roaming, the operating system must support roaming profiles and the feature must be enabled.
This example displays the path for storing the current user's application data in a MessageBox.
MsgBox(My.Computer.FileSystem.SpecialDirectories.CurrentUserApplicationData)
Namespace: Microsoft.VisualBasic.MyServices
Class: SpecialDirectoriesProxy (provides access to SpecialDirectories)
Assembly: Visual Basic Runtime Library (in Microsoft.VisualBasic.dll)
Project type
Available
Windows Application
Yes
Class Library
Console Application
Windows Control Library
Web Control Library
Windows Service
Web Site
The following permission is required:
Permission
Description
FileIOPermission
Controls the ability to access files and folders. Associated enumeration: Unrestricted.
For more information, see Code Access Security and Requesting Permissions.