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

23 次查看(过去 30 天)
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 个评论
Walter Roberson
Walter Roberson 2022-5-23
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 2022-5-23
编辑:Matthaeus leimer 2022-5-23
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...

请先登录,再进行评论。

回答(1 个)

Abhishek Chakram
Abhishek Chakram 2023-12-26
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

类别

Help CenterFile Exchange 中查找有关 Simulink 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by