Edit: This method is now available internally with File.DirData.
Windows apps are installed by default under Program Files. Starting from Windows Vista, Program Files folders are read-only. This means that writing to File.DirApp will fail.
The following code returns a writable folder based on the platform:
It will return something like: C:\Users\H\AppData\Roaming\AppName on Windows and File.DirApp on other platforms.
Windows apps are installed by default under Program Files. Starting from Windows Vista, Program Files folders are read-only. This means that writing to File.DirApp will fail.
The following code returns a writable folder based on the platform:
B4X:
Sub GetDataFolder (AppName As String) As String
Dim os As String = GetSystemProperty("os.name", "").ToLowerCase
If os.Contains("win") Then
Dim wf As String = File.Combine(GetEnvironmentVariable("AppData", ""), AppName)
File.MakeDir(wf, "")
Return wf
Else
Return File.DirApp
End If
End Sub
Last edited: