Rename file with editfield(App designer)

조회 수: 2 (최근 30일)
Siria Fumagalli
Siria Fumagalli 2019년 11월 20일
댓글: Siria Fumagalli 2019년 11월 20일
Hello,
I'm using App designer and I'm tryng to change the name of a file with the name writtend on a text edit field.
For example if i have 'oldname.txt' i want to be able to change it in a name i write in an edit field
How can i do it?

채택된 답변

Ajay Kumar
Ajay Kumar 2019년 11월 20일
편집: Ajay Kumar 2019년 11월 20일
You can do this. Suppose you entered 'oldname' in text editfield. i.e.
your_editfield.Value = 'oldname';
now save the file using the name
yourfile = % your character array
size_file = size(yourfile);
doc_name = [your_editfield.Value, '.txt'];
fid = fopen(fullfile(yourpath,doc_name),'w');
for i= 1:size_file(1)
fprintf(fid, '%s\n',yourfile(i,:));
end
fclose(fid);
  댓글 수: 5
Ajay Kumar
Ajay Kumar 2019년 11월 20일
yourfile = 'filecompl.txt';
doc_name = [app.NomeFileEditField.Value, '.txt'];
movefile(yourfile,doc_name)
Siria Fumagalli
Siria Fumagalli 2019년 11월 20일
This works perfectly, thank you

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by