Sony's Developer World forum

    • Home
    • Forum guidelines

    exists() on the sd

    Spresense
    2
    3
    2268
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    This topic has been deleted. Only users with topic management privileges can see it.
    • B
      Ben eaton last edited by

      anyone got the correct syntax for checking if a file exists on the SD?

      can't seem to get a positive return

      cheers

      b

      1 Reply Last reply Reply Quote
      • K
        KamilTomaszewski DeveloperWorld last edited by

        Hi @Ben-eaton,

        You can try this:

          // Open the file for reading
          myFile = File("/mnt/sd0/test.txt");
        
          if (myFile) {
            // File test.txt exists
          
            // Close the file
            myFile.close();
          } else {
            // File test.txt does not exist
          }
        

        Best regards,
        Kamil

        B 1 Reply Last reply Reply Quote
        • B
          Ben eaton @KamilTomaszewski last edited by

          @KamilTomaszewski

          thanks

          • managed to get the exists() working not sure what i was doing wrong first time round

          b

          1 Reply Last reply Reply Quote
          • First post
            Last post
          Developer World
          Copyright © 2021 Sony Group Corporation. All rights reserved.
          • Contact us
          • Legal