How do I lock the current directory while a GUI-based program is running?
Mostrar comentarios más antiguos
Hello, I've got a large GUI-based program that I'd like to error-proof by ensuring that the user doesn't change the current directory.
E.g., if she changes the directory, and then tries to close the program, an error comes up because MATLAB can no longer find the CloseRequestFcn. :( Same goes for countless other cases.
Any idea how this might be done? (My backup plan is to just make the main GUI window modal, preventing any other MATLAB window from being selected.)
Respuesta aceptada
Más respuestas (2)
Arthur
el 23 de Mzo. de 2012
Why don't you simply add your path to the MATLAB search pad? Then you'll never have this problem. If you want, you can even add this to the openingFcn of your GUI.
doc addpath
GUI_script = mfilename(); %name of the file
GUI_path = mfilename('fullpath'); %full path including filename
GUI_path = regexprep(GUI_path,GUI_script,'');%full path without file name
%add GUI path to search pad
addpath(GUI_path)
SAIM HAQUE
el 23 de Mzo. de 2012
0 votos
hello, ALEX, i'have some suggestion, just right click to any folder, and select "ADD PATH"-->"Select folders and sub folders".
In this way, you place m-file into any other folder and acceess it easily.
Categorías
Más información sobre Search Path en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!