still problems working with files [obsolete]

Posted on
  • Good morning!

    I still have my problems working with StorageFiles.

    When I try

    const Storage = require('Storage');
      function compareFileWith (expectedContent) {
        let readText ='4testing','r').read();
        if (readText != expectedContent) {
          print('>>>> file does not look as expected');
          print('>>>> expected "' + expectedContent + '"');
          print('>>>> got "' + readText + '"');
    /**** create file ****/
      let TestFile ='4testing','w');
      if (TestFile.write('4testing','Hello, World!')) {
        print('file "4testing" was successfully created');
      } else {
        print('file "4testing" could not be created');
      compareFileWith('Hello, World!');

    I only get the following output

    file "4testing" could not be created
    >>>> file does not look as expected
    >>>> expected "Hello, World!"
    >>>> got "undefined"

    Thus, how can I create a new file if I must not mix Storage methods with StorageFile ones?

  • Oops - I found my mistake: I should replace

    if (TestFile.write('4testing','Hello, World!')) {


    if (TestFile.write('Hello, World!')) {

    shouldn't I?

    Sorry for bothering you!

  • Thr 2020.01.09

    Glad to see the solution worked through @Andreas_Rozek

    For those seeking the reference link for read and write­le

    other suggested use snippet examples­329768/

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

still problems working with files [obsolete]

Posted by Avatar for Andreas_Rozek @Andreas_Rozek