Add directory path to fopen

3 visualizaciones (últimos 30 días)
Graur Alin
Graur Alin el 7 de Jul. de 2015
Comentada: Azzi Abdelmalek el 7 de Jul. de 2015
I have this code:
name = strrep(name,' ','_');
date = strrep(date,' ','_');
FileName=[name '_' date '.txt'];
file=fopen(FileName,'wt');
it creates a text file with the name and date I get from some edittext box in GUI in the current folder.
Can I add a directory path to that so it creates the text file in another folder like: ../DB/filename.txt ?

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 7 de Jul. de 2015
file=fopen(fullfile(pwd,FileName),'wt')
  2 comentarios
Graur Alin
Graur Alin el 7 de Jul. de 2015
Ok, it does the same thing. Let me explain again what I really need. This function creates the text file in the current work folder, let's say /Work/name_date.txt. I need it to create the text file in another folder inside the Work folder, like /Work/DB/name_date.txt.
Azzi Abdelmalek
Azzi Abdelmalek el 7 de Jul. de 2015
f=fullfile([pwd '\DB'],'name_date.txt')

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre File Operations en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by