B4J Question File.DirApp returns 'short filename' system

Jim Brown

Active Member
Licensed User
Running a simple console test app on Windows 7 the File.DirApp is returning the 'short' filename system but I need the long file system. Example:

B4X:
' console app - Test File.DirXX output
#Region  Project Attributes
    #CommandLineArgs:
#End Region

Sub Process_Globals
End Sub

Sub AppStart (Args() As String)
    Log(File.DirApp)
    Log(File.DirTemp)
End Sub

Output:
File.DirApp returns "D:\BASICJ~1\CONSOL~1\Objects"
File.DirTemp returns "C:\Users\Owner\AppData\Local\Temp\"

Can this be fixed so that File.DieApp returns the long file system method?
 
Last edited:

Theera

Well-Known Member
Licensed User
If I don't forget,Hotshoes' library can done.
 
Upvote 0

Erel

Administrator
Staff member
Licensed User
File.DirApp is based on a system property. It returns the value as is.

In most cases it doesn't matter whether you hold the short name or the long name. You can use this code to get the full name:
B4X:
Sub GetCanonicalPath(Path As String) As String
   Dim fileO As JavaObject
   fileO.InitializeNewInstance("java.io.File", Array As Object(Path))
   Return fileO.RunMethod("getCanonicalPath", Null)
End Sub
 
Upvote 0

coyote

Member
Licensed User
When I open the windows explorer with:
B4X:
Sub mnu_explorer_Action
   Dim x As String = File.DirApp
   Log(GetCanonicalPath(x))
   fx.ShowExternalDocument(File.GetUri(File.GetFileParent(x),""))
   
End Sub

The explorer shows the "short version".
Is there an other way to show the "long version"?

Coyote
 
Upvote 0

B4JExplorer

Active Member
Licensed User
Outside of the IDE, does DirApp return the folder name, where the jar is located?

Inside the IDE, it returns the project root, plus the \Objects subfolder.

I just want to make sure that the executable/jar location can be determined, because we're putting a configuration file in the same folder.
 
Upvote 0
Top