Filter löschen
Filter löschen

"exist" command usage question

3 Ansichten (letzte 30 Tage)
Raldi
Raldi am 14 Jan. 2012
Hello everyone. I wanted to know if it is possible to use a the "exist" command to check if a directory exists, nomater the username of the user eg. check=exist('C:\Users\<user_name>\---\---\---\somedit','dir') Is there a way to somehow get the username or something?

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 14 Jan. 2012
You can retrieve the username by using getenv('USERNAME') in MS Windows
I would suggest that you probably want to use getenv('HOMEPATH') as the base location for the directory to store files.

Weitere Antworten (1)

Andreas Goser
Andreas Goser am 14 Jan. 2012
I'd say once you know the file exits on the path, the WHICH command will also be able to find the file - and return the path. Only thing left is to do a reasonable string operation to isolate the username part.

Kategorien

Mehr zu Search Path finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by