MATLAB: Error using websave

copycontenttofiledropboxfopenloopMATLABParallel Computing Toolboxparforurlurlwritewebsavewrite

Why am I receiving an error using websave?
error using websave (line 107)
Unable to open output file: 'C:\Users\aaa\Dropbox\aaa.txt' for writing.
Common reasons include that the file exists and does not have write permission or the folder does not have write permissions.
These are new files and I have write permissions. I am running this inside a "parfor" loop with many urls.

Best Answer

This error is indicating that the file does not exist or that there are no write permissions to this file.
In this case, there are no write permissions only at the exact instant the websave is called in the parfor loop and not otherwise.
This is because the file is being saved and deleted from a Dropbox folder. If the Dropbox folder is connected to the internet, it will constantly be syncing. This can cause delays in when files are saved and deleted and can therefore cause write issues.
Save the files to a local folder or turn off the Dropbox connection to the internet so it does not automatically sync.