Effacer les filtres
Effacer les filtres

Rename file with editfield(App designer)

2 vues (au cours des 30 derniers jours)
Siria Fumagalli
Siria Fumagalli le 20 Nov 2019
Commenté : Siria Fumagalli le 20 Nov 2019
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?

Réponse acceptée

Ajay Kumar
Ajay Kumar le 20 Nov 2019
Modifié(e) : Ajay Kumar le 20 Nov 2019
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 commentaires
Ajay Kumar
Ajay Kumar le 20 Nov 2019
yourfile = 'filecompl.txt';
doc_name = [app.NomeFileEditField.Value, '.txt'];
movefile(yourfile,doc_name)
Siria Fumagalli
Siria Fumagalli le 20 Nov 2019
This works perfectly, thank you

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Develop Apps Using App Designer dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by