Browsing for a folder
We have seen how to browse a folder using the File Management
codeunit. Unfortunately, we do not have any function that will help us to browse folders. To overcome this, we will use automation control that should be already installed on your Windows.
How to do it...
Create a new codeunit from Object Designer.
Add the following global variables:
Name
Type
Subtype
Length
MSShell
Automation
'Microsoft Shell Controls
And Automation'.Shell
Folder
Automation
'Microsoft Shell Controls
And Automation'.Folder3
FilesInFolder
Automation
'Microsoft Shell Controls
And Automation'.
FolderItems3
CurrentFile
Automation
'Microsoft Shell Controls
And Automation'.
FolderItem2
SelectedFolder
Text
1024
Write the following code in the
OnRun
trigger of the codeunit:CREATE(MSShell, FALSE, TRUE); Folder := MSShell.BrowseForFolder(0, 'NAV Folder Browser', 0); FilesInFolder := Folder.Items(); CurrentFile := FilesInFolder.Item(); SelectedFolder...