Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat
How to get the Path of a File - Gideros Forum

How to get the Path of a File

MillerszoneMillerszone Member
edited September 2011 in General questions
In corona I used this to find get the file path:
local path = system.pathForFile( "data.txt", system.DocumentsDirectory )

Tried this, but no go.
local path = io.open("|D|date.txt", "rt")

Comments

  • atilimatilim Maintainer
    edited September 2011
    You're on the right way :)

    In corona, to open and read contents of a file in documents directory, you use:
    local path = system.pathForFile( "data.txt", system.DocumentsDirectory ) 
    local f = io.open(path, "rt")
    local t = f:read("*all")
    f:close()
    In Gideros, we don't allow users to get the directory paths. Because, in the future, we plan to port Gideros to different platforms which doesn't even have a file system. Therefore, to open a file on the documents directory, simply use "|D|data.txt" as the filename:
    local f = io.open("|D|data.txt", "rt")
    local t = f:read("*all")
    f:close()
  • atilimatilim Maintainer
    edited September 2011
    btw, I hope you like the new forum :)

    To highlight your Lua code, you can try

    <pre lang="lua">
    print("hello")
    </pre>

    which results
    print("hello")
    Also there are different highlighters available such ac "objc" or "xml" besides "lua".

    Likes: gorkem

    +1 -1 (+1 / -0 ) Share on Facebook
  • btw, I hope you like the new forum :)

    To highlight your Lua code, you can try

    <pre lang="lua">
    print("hello")
    </pre>

    which results
    print("hello")
    Also there are different highlighters available such ac "objc" or "xml" besides "lua".
    New forum looks good and easy to use like Gideros.
    Testing prefix for showing an image.
    image
Sign In or Register to comment.