Remove the slprj folder programmatically

조회 수: 183 (최근 30일)
Bonpland
Bonpland 2018년 11월 21일
댓글: Mostaza Con huevos 2021년 2월 12일
There is an 'slprj' in the working directory that is from another Simulink version. Consequently, I receive the error
'The existing Simulink code generation folder in the current folder was created for a different version of MathWorks products. This project folder is not compatible with the current version. To continue you must manually remove the slprj folder and any generated code files it contains.'
when trying to compile my model. However, I do not want to manually remove the folder each time. The programmatic approach via
rmdir('slprj')
from the MATLAB command line also issues an error.
So how can I programmatically remove the 'slprj' folder?
  댓글 수: 9
Bonpland
Bonpland 2018년 11월 21일
That would have been my first explanation. However, manually removing this folder is possible without issues.
Mostaza Con huevos
Mostaza Con huevos 2021년 2월 12일
someone else can helpme whit the folder slprj all the folder.

댓글을 달려면 로그인하십시오.

답변 (3개)

Sean de Wolski
Sean de Wolski 2018년 11월 21일
What about with the 's' option
rmdir('slprj', 's')
  댓글 수: 2
Gordon Lai
Gordon Lai 2020년 4월 2일
The full path version of this worked for me as 'slprj' is not empty (nor is it usually).
Note: I first added it and subfolders to the MATLAB path, using
addpath(genpath(pwd))
(unsure if that is necessary)
Sean de Wolski
Sean de Wolski 2020년 4월 2일
편집: Sean de Wolski 2020년 4월 2일
Typically if you're calling addpath/genpath, you should be using a project. This also lets you customize code generation settings at a project level.

댓글을 달려면 로그인하십시오.


Jan
Jan 2018년 11월 21일
편집: Jan 2018년 11월 21일
This does not solve the problem, but helps to identify the problem: Catch the error message:
[status, msg] = rmdir('slprj')
if status ~= 1
fprintf(2, '%s\n', msg);
end
By the way, of course you can use absolute path names even on different platforms. This does not mean a hard coded path name, but that you do not rely on the current directory to be, what you expect. Remember that each timer and GUI callback can use cd to change the current directory, and rmdir('slprj') might access an unexpected folder. Better:
baseFolder = cd; % Or even better: define it with a meaningful folder
[status, msg] = rmdir(fullfile(baseFolder, 'slprj'))
if status ~= 1
fprintf(2, 'Folder: %s\nProblem: %s\n', ...
fullfile(baseFolder, 'slprj'), msg);
end
Now the error message should be more useful.
  댓글 수: 4
Bonpland
Bonpland 2018년 11월 22일
편집: Bonpland 2018년 11월 22일
Sorry, I do not unterstand what you're looking for, especially with the last paragraph of your last comment. So, let me reiterate the facts:
1) As expected, the output of your script is just a recurring
Folder: D:\dev\slprj
Problem: No directories were removed.
...retrying...
The status is '0'.
2) The folder 'slprj' may be removed manually from the MATLAB GUI or in the Windows Explorer.
3) Creating a new folder 'slprj' manually somewhere else and trying to delete it programmatically in MATLAB is also no issue.
From 1)-3) I infer that the automatic creation of the folder 'slprj' is imposing some kind of access restriction which cannot be circumvented from within MATLAB. However, this is in no way contained in the error message.
Any help would be greatly appreciated.
Jan
Jan 2018년 11월 29일
The next question: What does "There is an 'slprj' in the working directory that is from another Simulink version" mean? Is "the other Simulink version" still running?

댓글을 달려면 로그인하십시오.


Bonpland
Bonpland 2018년 11월 29일
Are there any news on this issue?
It would be good to have at least a feedback on how this problem is perceived by MathWorks.
  댓글 수: 1
Jan
Jan 2018년 11월 29일
Please do not post a pseudo-answer only to bump your question. This wastes the time of all readers. This is the public forum. If you want MathWorks to react to your question, contact them directly using the "Contact Us" link on top of this page.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Simulink에 대해 자세히 알아보기

태그

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by