B4J Code Snippet Data Folder

Discussion in 'B4J Code Snippets' started by Erel, Aug 3, 2015.

  1. Erel

    Erel Administrator Staff Member Licensed User

    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:
    Sub GetDataFolder (AppName As StringAs 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
    Return File.DirApp
    End If
    End Sub
    It will return something like: C:\Users\H\AppData\Roaming\AppName on Windows and File.DirApp on other platforms.
    Last edited: Jan 3, 2016
  2. ThRuST

    ThRuST Well-Known Member Licensed User

    Does File.DirApp contains the project folder on non-Windows systems? Because it is not created in the above routine. So where is File.DirApp on Mac etc?
  3. Erel

    Erel Administrator Staff Member Licensed User

    This thread has nothing to do with File.DirApp.
    Please start a new thread for your question.