Skip to main content
Inspiring
Aug 13, 2025 3:29 AM UTC
Answered

Use importTextData / Want to open to a file directory only / Then user picks file

I have a trusted function to import a text file from a button.   It works fine when I specify the file path including a specific text file.  I am wanting to open to the file directory and let the user select from the .txt files in that folder.  If I don't include an actual file.txt name, nothing happens, the path to the directory with the text files does not open.  The code I'm trying to use with the button is:

 

var thepath = getCurrentDirectory;

myImportTextData(thepath);

 

My trusted function code is:

 

myImportTextData = app.trustedFunction(function(cPath)
{
app.beginPriv();
this.importTextData(cPath);
app.endPriv();
});

 

try67
try67Correct answer
Community Expert
Aug 13, 2025 9:33 AM UTC

You can't specify the default folder to open the dialog to, if that's what you mean.

5 replies

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
Aug 13, 2025 9:33 AM UTC

You can't specify the default folder to open the dialog to, if that's what you mean.

Translate
wes@ESAAuthor
Inspiring
Aug 14, 2025 1:17 PM UTC

Thank you for your reply.  Yes that's what I'm trying to do.  Using importTextData() without a specific path to a file opens up the wrong directory.  User has to navigate on their own to find what I'm trying to import.  

Translate
Nesa Nurani
Community Expert
Community Expert
Aug 13, 2025 5:00 AM UTC

Try this:

button script:

myImportTextData();


Trusted function:

myImportTextData = app.trustedFunction(function() {
app.beginPriv();
this.importTextData(); 
app.endPriv();
});

Translate
wes@ESAAuthor
Inspiring
Aug 14, 2025 1:23 PM UTC

Thank you for your reply.   When I don't specify a path to a specific file the dialogue box opens up showing the wrong directory.  User has to navigate on their own to find what I'm trying to import.  The directory I wanted to point to has three different text files that the user can select.

 

Translate
Nesa Nurani
Community Expert
Community Expert
Aug 14, 2025 3:53 PM UTC

It will open the last folder that you imported the file from, so if you wish it to be a specific folder just import the file from it and next time it will open that folder by default.

Translate