Just to add to this as well, the DIR code does work if I go into the folder on the sharepoint manually first before running the DIR code.