MATLAB doesn't find my files I downloaded while the script is running

Hello,
My problem is as described. My script downloads files through an external call to cmd (using the system function and then .NET to make keypresses). The issue is that when it tries to fopen these files I downloaded (filenames from a text file I write as I download), it doesn't find them, causing an error. When I run the script again after seeing it fail, it works but only up to the point where it's trying to download/call new files again, where it runs into the same problem.
Are new files downloaded during when a script is running somehow not visible to the search path? Because the folder is most definitely in my search path (seeing as it works outside of during-script downloads). It's not that it isn't getting the files fast enough either, cause they appear in my folder almost instantly, and I've tried a delay to allow for it to recognize it, but that didn't work either.
I'm not sure if it's important to note that the script calls an external function which tries to read the files from the .txt list I create in the main script.
Any ideas?
Thank you,
Aaron

 Accepted Answer

Files are available immediately to fopen(), but you can remove all possible search path problems by fully qualifying the filename using fullfile()
download_dir = 'C:\MyThesis\CatPictures\Download';
thisfile = fullfile(download_dir, 'grumpy.txt');
fid = fopen(thisfile, 'rt');

2 Comments

I ended up using rehash to refresh the files available.
rehash would apply only if it was .m or .p or .mex* or .dll files.

Sign in to comment.

More Answers (0)

Categories

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!