How to create new file in another folder?
Afficher commentaires plus anciens
I have got 2 files namely DCM file and text file.I have to compare the parameters in text file and Dcm file and if those parameters presented, then I have to copy the parameters from DCM file to another new file. I have already written the code in such a way it will do this. But I have create the new file in another folder . How can I do this?
3 commentaires
Joel Handy
le 20 Août 2019
Are you asking how to create a folder or how to write to a file outside of your working directory? To open a file for writing outside of your working directory, you just need to supply the full path.
fid = fopen('C:\MyFolderA\MyFolderB\MyFile.txt', 'w+')
To make a new folder is pretty similar.
mkdir('C:\MyFolderA\MyFolderB')
mkdir will make all the necessary folders on the supplied path.
You can also do relative paths where you give a path relative to your working path. If you weer working in C:\MyFolderA and you called
mkdir('MyFolderB\MyFolderC')
It would create C:\MyfolderA\MyFolderB and C:\MyfolderA\MyFolderB\MyFolderC
Naga
le 20 Août 2019
Joel Handy
le 20 Août 2019
There are lots of commands for that. Can you be more specific when you say the other function can't read the file? Do you get an error? Do you get unexpected results? What code have you tried so far?
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Entering Commands dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!