How do I read a text file using nwjs, the ReadFile(path) is not there in the actions?

Not favoritedFavorited Favorited 0 favourites
  • 4 posts
From the Asset Store
Convert multiple Excel files into JSON files and import them into construct3.
  • I was able to use Write a text file and managed to save text to a file, the folder an path are there. But I don't see any option anywhere for reading a text file or "ReadFile(path)" as the documentation says.

    (please don't ask me why I need to, that's not important if its just a simple line of text.)

    Tagged:

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • In the NW.js object, there is a ReadFile expression (not an action) that synchronously reads the content of a file and returns the content as a string.

    However I would advise using the File System object with one of the newer export options. NW.js is deprecated so will be removed in future, and the File System object can read files asynchronously which is usually better for performance and avoiding jank.

  • I don't know why accessing files is so hard for me. I had looked at using the file system and didn't get that working either but I'll take another look at it. Doesn't it have all sorts of difficulties because of browsers not being able to access local files?

    If I am recalling correctly I had even tried to allow a save file or open file dialog box to appear and it just simply never appeared.

  • Answering your original question, here's how you can read text files with NWjs:

    Set var to NWJS.ReadFile("path")

    Another option that should work on any platform is with the FileChooser:

    | Global string s‎ = 
    + FileChooser: On changed
    -> AJAX: Request FileChooser.FileURLAt(0) (tag "tag")
    -> System: Wait for previous actions to complete
    -> System: Set s to AJAX.LastData
    
Jump to:
Active Users
There are 0 visitors browsing this topic (0 users and 0 guests)