Skip to content

Get the file fullname including directory #4797

Closed

Description

@itg-assistant

Rusty Elston asked 2025-06-20 14:02:48 UTC

Using the Clientfilesystem, (or other), is there a way to get the full path and name of the file?

If so, how?

Thanks

Activity

  1. itg-assistant commented on Jun 16, 2026

    @itg-assistant
    Author

    Julie (ITG) answered 2025-06-20 14:32:42 UTC

    Unfortunately, it's not possible due to browser security restrictions. You can only get the relative path within the shared folder.

    Julie

  2. itg-assistant commented on Jun 16, 2026

    @itg-assistant
    Author

    Rusty Elston answered 2025-06-20 14:41:53 UTC

    Thanks Julie,

    I don't understand "within the shared folder", what is the shared folder...?

  3. itg-assistant commented on Jun 16, 2026

    @itg-assistant
    Author

    Julie (ITG) answered 2025-06-20 16:07:46 UTC

    The shared folder is the folder that the user shares with the web application via the Client File System API. This is the folder that the user chooses from the dialog when you call this code:

    Directory directory = await ClientFileSystem.ShowDirectoryPickerAsync();
    

    I've created an example directory that looks like this:
    Example Folder
    -folder1
    ----file1.txt
    ----file2.txt
    -folder2
    -textfile.txt

    To get the relative path, you can use the "Name" property for each of the files and folders, then put it all together. For example here's how to get the relative path to file1.txt from the root folder (Example Folder):

    Directory directory = await ClientFileSystem.ShowDirectoryPickerAsync();
    
    //get all subdirectories, in this case folder1 and folder2
    Directory[] subDirectoryArray = await directory.GetDirectoriesAsync("*");
    
    //get folder1-it's the first one in the array
    Directory folder1 = subDirectoryArray[0];
    
    //get file1.txt from folder1
    File[] fileArray = await folder1.GetFilesAsync("file1.txt");
    
    //get the first (and only) file from the array
    File file = fileArray[0];
    
    //Put together the filepath based on the Name property
    AlertBox.Show("filepath: "+folder1.Name+"\\"+file.Name);
    

    I've attached the sample project and the sample directory.

    Download both, and when you run the sample project, after clicking the button, select the sample directory (Example Folder). Doesn't matter where you put it in your filesystem as the browser will only have access to the files within the sample directory.

    See also:
    https://docs.wisej.com/extensions/extensions/clientfilesystem
    https://developer.mozilla.org/en-US/docs/Web/API/File_API

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    GeneralQuestions, how-tos and everything else.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions