B4J Question How to open a new window showing the directory?

Solution



Obtained with:
B4X:
Sub Button1_Click
    OpenSearch("D:\Documents\AnywhereSoftware\AdditionalLibs\B4X","sl")
End Sub

Private Sub OpenSearch(Path As String,SearchTerm As String)
 
    Dim FileExtns As String
    FileExtns = "&crumb="

    FileExtns = FileExtns & "fileextension%3A.b4xlib?"
    Dim DisplayName As String = $"&displayname=b4xlib"$
    Dim SU As StringUtils
    Path = SU.EncodeUrl(Path,"UTF8")
    Dim SearchTerm As String = $"&crumb=System.Generic.String%3A${SU.EncodeUrl(SearchTerm,"UTF8")}"$
    fx.ShowExternalDocument($"search-ms:${DisplayName}${SearchTerm}${FileExtns}&crumb=location:${Path}"$)
End Sub

stevel05

Expert
Licensed User
Longtime User
You need to search for "search-ms" and "crumb" in relation to the Windows File explorer.

Here is some code that I ripped out of an app and got working stand alone. I can't really remember exactly how it all fit's together (I wrote it a good few years ago) but I know it works. It may point you in the right direction.

B4X:
Sub Button1_Click
    OpenSearch("D:\","test")
End Sub

Private Sub OpenSearch(Path As String,SearchTerm As String)
   
    Dim FileExtns As String
    FileExtns = "&crumb="

    FileExtns = FileExtns & "fileextension%3A.b4?"
    FileExtns = FileExtns & "%20OR%20"
    FileExtns = FileExtns & "fileextension%3A.bas"
    FileExtns = FileExtns & "%20OR%20"
    FileExtns = FileExtns & "fileextension%3A.css"
    FileExtns = FileExtns & "%20OR%20"
    FileExtns = FileExtns & "fileextension%3A.txt"
   
    Dim DisplayName As String = $"&displayname=Search%20Results%20in%20Search"$
    Dim SU As StringUtils
    Path = SU.EncodeUrl(Path,"UTF8")
    Dim SearchTerm As String = $"&crumb=System.Generic.String%3A${SU.EncodeUrl(SearchTerm,"UTF8")}"$
    fx.ShowExternalDocument($"search-ms:${DisplayName}${SearchTerm}${FileExtns}&crumb=location:${Path}"$)
End Sub
 
Last edited:
Upvote 0

Magma

Expert
Licensed User
Longtime User
Upvote 0

T201016

Active Member
Licensed User
Longtime User
Hi everyone,
I have included a test project, but under no circumstances can I open a Windows window with File Explorer along with the B4X Library (.b4xlib) files ("SEARCH" as a result).

Rather, an attempt is made to open the searched file for editing, and all I expect is to open a view window with the searched files (.b4xlib) that are not associated with any program on the system. Hence the problem.
 

Attachments

  • shell.zip
    3 KB · Views: 112
Last edited:
Upvote 0

T201016

Active Member
Licensed User
Longtime User

Hi, @stevel05

Interesting direction, but I will check if an example will work for me - when handling files like .b4xlib?
Because these are the types of files that I care about.

Thanks to everyone for the attention and help for a moment.
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
That's a different question really. If I understand what you are asking is to show the contents of a zipped file in Windows explorer.

As you say, Windows would need to know about b4xlib files. Does it work as you want it with with zip files?
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Does it work as you want it with with zip files?
It appears to I tested it myself:

B4X:
fx.ShowExternalDocument("D:\Documents\AnywhereSoftware\B4j\UserAppsForHelp\T201016\shell.zip")

So one option could be to rename the b4xlib to a .zip file, open it, then change it back again when you've finished.

Or if you are only looking at it and not changing anything, you could copy the b4xlib to a zip file, then delete the copied file when you are done.
 
Upvote 0

T201016

Active Member
Licensed User
Longtime User
That's a different question really. If I understand what you are asking is to show the contents of a zipped file in Windows explorer.

As you say, Windows would need to know about b4xlib files. Does it work as you want it with with zip files?

Yes, my point is to show ONLY the displayed LIST of files in Windows Explorer.

Indeed, Windows has no information about files of this type and by default it wants me to open the file for editing with the expected program.
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
If it is just for your use on your PC you may be able to associate the b4xlib type with windows explorer.
 
Upvote 0

T201016

Active Member
Licensed User
Longtime User

I just want a list of collections, I don't want to open or edit files.
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Just the content of the directory?
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User


Obtained with:
B4X:
fx.ShowExternalDocument("D:\Documents\AnywhereSoftware\AdditionalLibs\B4X")
 
Upvote 0

T201016

Active Member
Licensed User
Longtime User
If it is just for your use on your PC you may be able to associate the b4xlib type with windows explorer.
Exactly, I haven't tried to associate the b4xlib type with Windows Explorer yet. OK, something is dawning ?
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
But you want to search it right?
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User



Obtained with:
B4X:
Sub Button1_Click
    OpenSearch("D:\Documents\AnywhereSoftware\AdditionalLibs\B4X","sl")
End Sub

Private Sub OpenSearch(Path As String,SearchTerm As String)
 
    Dim FileExtns As String
    FileExtns = "&crumb="

    FileExtns = FileExtns & "fileextension%3A.b4xlib?"
    Dim DisplayName As String = $"&displayname=b4xlib"$
    Dim SU As StringUtils
    Path = SU.EncodeUrl(Path,"UTF8")
    Dim SearchTerm As String = $"&crumb=System.Generic.String%3A${SU.EncodeUrl(SearchTerm,"UTF8")}"$
    fx.ShowExternalDocument($"search-ms:${DisplayName}${SearchTerm}${FileExtns}&crumb=location:${Path}"$)
End Sub
 
Last edited:
Upvote 0
Solution

T201016

Active Member
Licensed User
Longtime User

OK.
That was what I meant.
Thank you very much for your help. Now I can implement it boldly in the project.
 
Upvote 0

T201016

Active Member
Licensed User
Longtime User
... a small fix to thread #17
this change improves the "+" sign in the folder path.

Correction: fix from SU.EncodeUrl to SU.DecodeUrl:
'Show the b4xlib archive file
Private Sub btnShowLib_Click
    Dim FileName As String = tflibTarget.Text
    OpenSearch(lblB4xLibDeploy.Text,FileName)
End Sub

'Open search results in the Libs folder
Private Sub OpenSearch(Path As String, SearchTerm As String)
    
    Dim FileExtns As String
    FileExtns = "&crumb="

    FileExtns = FileExtns & "fileextension%3A.b4xlib?"
    Dim DisplayName As String = $"DisplayName=Wyniki%20wyszukiwania%20w%20folderze%20Libraries"$
    Dim SU As StringUtils
    
    Path = SU.DecodeUrl(Path,"UTF8")
    Dim SearchTerm As String = $"&crumb=System.Generic.String%3A${SU.DecodeUrl(SearchTerm,"UTF8")}"$
    fx.ShowExternalDocument($"search-ms:${DisplayName}${SearchTerm}&crumb=location:${Path}"$)
    
End Sub
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…