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

9 views (last 30 days)
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

Walter Roberson
Walter Roberson on 2 Sep 2015
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');

More Answers (0)

Categories

Find more on Downloads in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!