Why am I getting the error "Failed to create or open file system output stream"?

29 views (last 30 days)
When I try to save my simulink model which I have imported from version 2018b to .mdl file i get following error:
Saving the model to .slx file is working.
Matlab is running with Admin rights.
  2 Comments
Walter Roberson
Walter Roberson on 23 May 2022
Does the Temp directory exist? How about the directory all the way down to bdmxdata ?
Is there a particular reason you are runing with Admin rights?
Matthaeus leimer
Matthaeus leimer on 23 May 2022
Edited: Matthaeus leimer on 23 May 2022
Yes the directory until /Temp exists.
But the folder (in this particular case, because the name always changes) ".cddb-0587-7c42-3f15.tmp_modified_package_Model1.mdl" does not exist. It seems that it is created during the save process and is only vissible for arround 2 seconds until the error msg appears.
I am always running Matlab / Simulink with Admin rights to avoid unexpected errors...

Sign in to comment.

Answers (1)

Abhishek Chakram
Abhishek Chakram on 26 Dec 2023
Hi Matthaeus leimer,
I understand that you are facing difficulty in saving a Simulink file in “.mdl” format. The “.mdl” file format was used in MATLAB R2018b and earlier. While newer versions of MATLAB can still open and save “.mdl” files for backward compatibility, there may be issues related to the conversion process or file access permissions. Here are few steps to resolve the issue:
  1. File Path Length: The error message suggests that MATLAB is trying to write to a temporary file with a very long path. Windows has a maximum path length limitation (MAX_PATH) of 260 characters. Try saving the file to a directory with a shorter path to avoid hitting this limit.
  2. Temporary Folder Permissions: MATLAB is attempting to write to a temporary folder within the user's AppData directory. Ensure that MATLAB has the necessary permissions to write to this folder. Although you mentioned that MATLAB is running with admin rights, it's worth double-checking the specific folder permissions.
  3. Clear Temporary Files: Clear out MATLAB's temporary files by using the “tempdir” command to find the temp directory and manually deleting the files, or by restarting MATLAB, which should clear its temporary state.
  4. Save As Different Name: Try saving the model with a different name or in a different location to see if the issue is specific to that file path or name.
You can refer to the following documentation to know more about the functions used:
Best Regards,
Abhishek Chakram

Categories

Find more on Simulink in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!