Hi all,
I am doing a small program so the user can select a folder on the local and the nav will search all files in that folder and put the path into a table. I use the following code to do the job. Right now I have 2 issues: one, will create "This Automation variable has not been instantiated... " message, even it displays all the path at the message function and second, is there a easier way to tell if the item is a folder or a file? Thanks
Shellcontrol Automation 'Microsoft Shell Controls And Automation'.Shell
Folder Automation 'Microsoft Shell Controls And Automation'.Folder3
FolderItems Automation 'Microsoft Shell Controls And Automation'.FolderItems3
IF ISCLEAR(Shellcontrol) THEN
CREATE(Shellcontrol);
Folder := Shellcontrol.BrowseForFolder(0,'Choose Folder',0);
IF ISCLEAR(Folder) THEN
EXIT;
FolderItems := Folder.Items();
FolderItem := FolderItems.Item;
FOR I := 1 TO FolderItems.Count DO
BEGIN
message('%1', Folderitems.Item(I).Path);
tempRec.path := FolderItems.Item(I).Path;
tempRec.insert;
END;
(update)
Looks look this code doesn't like when user selected "Desktop".
0
Comments
FolderItem Count will return the total number, but the Item method is zero starting index. From MSDN:
Parameters
iIndex [in, optional]
Type: Variant
The zero-based index of the item to retrieve. This value must be less than the value of the Count property.
http://msdn.microsoft.com/en-us/library/bb787802(v=vs.85).aspx
Is this my 100th post?
"Profanity is the one language all programmers know best."
http://msdn.microsoft.com/en-us/library/bb787810(v=vs.85).aspx
"Profanity is the one language all programmers know best."
folderitems.item() is the folder itself
folderitems.item(0) is the first node inside the folder.
to get the correct path, you would need to parse the path and remove the file name
What if I already know the path name (folder name). Which command do I use for that ?
Folder := Shellcontrol.BrowseForFolder(0,'Choose Folder',0);
So in other words, I want to change the above line of code to assign the Folder variable to smth like '\\nav-sql\RSL\'
Any ideas ?