Access new created file

Completed

Hello,

 

I'm working on a plugin for my PHPStorm. Works like a charm so far. But sadly, I have a little hung here.

 

I'm starting an external process which creates a file in the project directory. After this, I want to open the desired file in the editor.

Problem: 

final VirtualFile theThestFile = LocalFileSystem.getInstance().findFileByPath(testFilePath);

does not find the file, as it returns null. When the file exists (when it can be seen in the project toolwindow), it loads the file.

I'm opening the file with

FileEditorManager.getInstance(project).openFile(theThestFile, true);

My thought is, that I need to tell PHPStorm to read the directories for new files, so it can open the new project file. Is that correct? The question here is: How?

If this is not my issue, please help me to find a solution. Thanks

 

1 comment
Comment actions Permalink

I fixed it with using 

final VirtualFile theThestFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(new File(testFilePath));

refreshAndFindFileByIoFile did the trick.

0

Please sign in to leave a comment.