Why am I receiving a "file may be corrupt" error when saving my file using "uiputfile"?
Show older comments
I use "uiputfile" in an application that I created using MATLAB R2020b to allow users to select a folder to subsequently use the "save" command and save .MAT files into the selected folder. Now the user is trying to use my code to write files onto a write only file system (i.e., deletion or modification of files is prohibited). The save command threw the following error:
Error using save.
Unable to write to MAT-file Q:\MyFiles\test.mat.
The file may be corrupt.
Upon debugging I saw that "uiputfile" creates a file with size 0 kb on the write only file system. Therefore, the subsequent save could not be performed. Is there a workaround for this issue?
The following is the sample code that I am currently using for my work-
[tempFileName, tempPathName] = uiputfile('*.mat', 'Save file', 'tempFileName');
MyTempFullName= fullfile(tempPathName, tempFileName);
if exist(MyTempFullName, 'file')
save(MyTempFullName, 'data', '-append')
else
save(MyTempFullName, 'data')
end
Accepted Answer
More Answers (0)
Categories
Find more on Whos 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!