Using dir to access files on WebApp Server
6 views (last 30 days)
Show older comments
I am creating a WebApp that needs to reference a set of data files located on the WebApp Server itself. The dir() function is supposed to list out the contents of the target directory and it is working on my local PC, however, when compiled as a WebApp dir() is returning an empty structure. I have checked that it is pointing at the correct folder, and other commands like load() and save() are working using the same directory on the WebApp Server. The behaviour is consistent with giving dir() a path that does not exist, as even pointing dir() at an empty folder typically returns two entries called "." and "..".
% Tested on my local PC
folder_contents = struct2table(dir('C:\Empty Folder that Exists')); % Returns a 2x6 table
folder_contents = struct2table(dir('C:\Folder that does not Exist')); % Returns a 0x6 empty table
% While on the WebApp server
folder_contents = struct2table(dir('C:\Folder that Exists and has contents'));
isempty(folder_contents) % Returns true
To be clear, the folder and files within it I am trying to access are on the same Virtual Machine as the WebApp Server and the compiled .ctf file.
The files within this folder will have unknown names so I cannot hard-code them into the WebApp ahead of time.
I've looked at the Web App Limitations and Unsupported Functionality page and the only thing mentioned there is uigetdir(), which I am not using.
Is there a trick to using dir() within a WebApp?
3 Comments
Accepted Answer
More Answers (0)
See Also
Categories
Find more on File Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!