Issues using dir() in a .exe file

조회 수: 1 (최근 30일)
Sadie
Sadie 2022년 7월 15일
답변: Piyush Dubey 2023년 6월 27일
My app (designed in app designer) when the start button is pressed, asks the user to select an input folder, then reads all files from the folder. This is the code that accomplishes that:
inputFolderName = uigetdir();
D = dir(inputFolderName);
When running the app from app designer, this works totally fine. However when packaged to a .exe file, it cannot find any files in the folder. I have tried putting .mat, .png, and a number of other files into the folder to see it is a filetype issue, but it always thinks it is empty.
  댓글 수: 2
Sadie
Sadie 2022년 7월 15일
I had the program print a few things to confirm. The filepath it is finding is correct. However, the size of D is 0.
Walter Roberson
Walter Roberson 2022년 7월 15일
I have a vague memory of seeing a bug report along these lines, but I do not recall which MATLAB version.

댓글을 달려면 로그인하십시오.

답변 (1개)

Piyush Dubey
Piyush Dubey 2023년 6월 27일
Hi Sadie,
When an app is packaged to a standalone .EXE file it is possible that the working directory gets modified and that may be the reason why relative paths are not being accessed.
The function ‘fullfile()’ can be used to construct an absolute path from parts of path. Below attached is the documentation to the same:
Hope this helps.

카테고리

Help CenterFile Exchange에서 File Operations에 대해 자세히 알아보기

태그

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by