MATLAB: How to get directory of Document folder in a non-MATLAB computer when using a fully standalone application

get directory of my document folder

Hi,
My fully standalone application prompts a message to choose where to save a file. When the message shows, the default folder which I want will be '….\My Document'. When I use 'uigetdir('Choose ') on my computer which has MATLAB it shows a MATLAB default folder '….\My Document\MATLAB'. So how about on a non-MATLAB computer? Will 'uigetdir' show '….\My Document'?
Welcome any helps.
Thanks.

Best Answer

Try this:
% Get the name of the user who logged in to the computer.
userProfile = getenv('USERPROFILE')
% Create a string to the "My Documents" folder of this Windows user:
myDocsFolder = sprintf('%s\\My Documents', userProfile)
In the command window:
userProfile =
C:\Users\Khanh
myDocsFolder =
C:\Users\Khanh\My Documents
Then you can call
usersChosenFolder = uigetdir(myDocsFolder);