Minor problem with File API



  • const var appDataFolder = FileSystem.getFolder(FileSystem.Samples);
    const var presetsFolder = appDataFolder.getChildFile("ExpansionMetaData");
    
    const var fileList = FileSystem.findFiles(presetsFolder, "*_expansion.json", true);
    
    Console.print(fileList[0].toString(fileList[0].Filename));
    

    doesnt seem to work - it returns the full path every time.

    this does work however:

    const var appDataFolder = FileSystem.getFolder(FileSystem.Samples);
    const var presetsFolder = appDataFolder.getChildFile("ExpansionMetaData");
    
    const var fileList = FileSystem.findFiles(presetsFolder, "*_expansion.json", true);
    
    Console.print(fileList[0].toString(fileList[0].NoExtension));
    

    OnlyExtension also doesnt work...



  • You don't need to put fileList[0].Filename, you just put the string constant. So in your case it would be Console.print(fileList[0].toString("Filename"));



  • @d-healey said in Minor problem with File API:

    Console.print(fileList[0].toString("Filename"));

    sure I can do that and it works(or more correctly - breaks) in exactly the same way:

    it prints out this:

    H:\Audio\Channel Robot\Hise_Work\Substrate\Samples\ExpansionMetaData\Substrate_expansion.json
    

    when it should print out this:

    Substrate_expansion.json
    


  • This post is deleted!


  • Ok I figured it out, your method was right Lindon. The constant is a member of the file object but Filename has not been implemented.

    f2e1fb56-c575-4aaf-a9c1-f6eed8c9a15c-image.png

    You can cheat it though since it's just an integer, use 3.
    Console.print(fileList[0].toString(3));

    @Christoph-Hart Little fixes required: According to docs File.Extension should be File.OnlyExtension, and File.Filename is missing.



  • Yup, use the int. Works for me.


Log in to reply
 

5
Online

965
Users

3.4k
Topics

29.4k
Posts