필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

saving user's search path

조회 수: 2 (최근 30일)
katerina
katerina 2014년 6월 26일
마감: MATLAB Answer Bot 2021년 8월 20일
i need to save the path that the user takes to select files. let's say i prompt the user to search in Desktop. but then in the search window they go to Documents/testfolder/anotherfolder/filename.txt or something similar. how can i save this path, so that when i need to parse the data, it can open it? i keep getting an error that says that my filename does not exist, so i'm assuming that is my problem.

답변 (2개)

Azzi Abdelmalek
Azzi Abdelmalek 2014년 6월 26일
편집: Azzi Abdelmalek 2014년 6월 26일
You can use uigetfile or uigetdir function

Joseph Cheng
Joseph Cheng 2014년 6월 26일
편집: Joseph Cheng 2014년 6월 26일
if it is inside a GUI at the start of the program define a variable CurrentDir or something similar and assign it to the default folder (in your example desktop or maybe c:\).
This way instead of hard coding the default folder you leave it as the defined variable CurrentDir inside uigetfile or uigetdir. Then when they navigate away save the returned directory as the CurrentDir. This way when it gets called again CurrentDir is replaced with the folder they were in.
I hope thats clear.
if it is inside a script *.m file you may need a check at the beginning of the script to see if CurrentDir is defined. If not then set to Default folder.

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by