"exist" command usage question
조회 수: 2 (최근 30일)
이전 댓글 표시
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?
채택된 답변
Walter Roberson
2012년 1월 14일
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.
댓글 수: 0
추가 답변 (1개)
Andreas Goser
2012년 1월 14일
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.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!