Accessing an Imported File

Can someone point me to the documentation that shows the proper syntax for accessing a file stored in my Project via the File/Import Menu? I’ve searched high and low for the syntax using FolderItem but am not getting anywhere. I have several .csv files I’ve been using but I’d like to avoid the requirement of having to store external files with the finished .exe.
Thanks,

Dan

If the CSV files are named file1.txt file2.txt and so on
and you drag them into your project in the IDE

They will be in the resources folder of the built app

And you can get at the contents in code by using the filename like a constant directly

eg

Var sometext as string
sometext = file1
//now do something with the sometext

but you cannot write back to it

I have drag and dropped a file “airports.tab” into my project. It appears as ‘airports’ in my IDE Contents.

I have tried both of the following and they fail where I test f.exists.

var j as string = airports
var f as new FolderItem(j, FolderItem.PathModes.Native)
var f as new FolderItem(j)

I’m still missing something. Thoughts?

Dan

You didn’t read what @Jeff_Tullin wrote:

Var sometext as string
sometext = airports
// now do something with the sometext

Are you saying I cannot use ‘sometext’ as a variable in FolderItem? I have edited my post and have the same syntax Jeff suggested and it still does not work. Sorry if I’m being dense.

Perhaps you are suggesting the entire contents of airports is now a string, not a file. And I can process it as a string. If so, that now seems obvious. Sorry I didn’t get it before.

1 Like

Perhaps you are suggesting the entire contents of airports is now a string, not a file

Correct. You don’t need to check for ‘exists’, you don’t need to open a TextInputstream.
What you have is a string as if you did a ‘readall’ on a file.

Also, remember that the file is included in your build application.

So, do not place sensible data (data not to be read by anybody).