I wanna save text as txt file in my desktop or any location I choose

3 vues (au cours des 30 derniers jours)
Mohammed alfath Ahmed
Mohammed alfath Ahmed le 15 Sep 2019
Text='hello' [file, path] =uiputfile('text. Txt')
  1 commentaire
dpb
dpb le 15 Sep 2019
You intended more like
Text='hello';
[file, path] =uiputfile([Text '.txt']);
maybe?

Connectez-vous pour commenter.

Réponses (1)

Walter Roberson
Walter Roberson le 15 Sep 2019
Text='hello';
[file, pathdir] = uiputfile('text. Txt');
if isempty(file); return; end %user cancel
fullname = fullfile(pathdir, file);
[fid, msg] = fopen(fullname, 'wt');
if fid < 0
error('Failed to open file "%s" because "%s"', fullname, msg);
end
fprintf(fid, '%s\n', Text);
fclose(fid);

Catégories

En savoir plus sur Dialog Boxes dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by