Writing and Reading from a created directory

Discussion in 'Programming' started by Laura Bravo, May 14, 2019.

  1. Laura Bravo

    Laura Bravo Member

    Joined:
    Jun 25, 2016
    Posts:
    21
    So I create a directory using directory_create(name) easy enough and it places said new directory within the working_directory. What I can't seem to figure out is how to place the path when writing and reading to do so withing the newly created directory leaving me only to write and read within the working_directory.

    I realize that GS is a self contained sand box but surely there is a way to do so within folders placed in the working_directory else why be able to create said folder and destroy them.

    Here is my file write line
    file = file_text_open_write(working_directory + "\ " + "c_times_" + string(date_id) + ".txt")
    this looks in the working_directory for a file named c_times_[ date_id goes here ].txt
    I can't seem to be able to set a path that allows saving within a newly created directory within working_directory. Any ideas? I have tried some things as well as using the whole file location name but non worked so don't think it would help to list them.
     
  2. TsukaYuriko

    TsukaYuriko Q&A Spawn Camper Forum Staff Moderator

    Joined:
    Apr 21, 2016
    Posts:
    1,487
    Remove working_directory, the backslash and especially the space after the backslash. Neither of these have a right to exist in relative file paths. Take a look at my post about how to included files for further information.

    Relative file paths have the following form:
    Code:
    folder/anotherfolder/filename.extension
    and are by default relative to the local storage or the working directory, depending on where the file exists, the former for reading and writing, the latter only for reading, prioritized in that order.


    That aside, make sure to not only open, but also close your file. Closing is what writes buffered contents to disk. Opening does nothing but open the buffer.
     
    Japster likes this.
  3. Laura Bravo

    Laura Bravo Member

    Joined:
    Jun 25, 2016
    Posts:
    21
    Thank you it works now.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice