Help!!! Is there a way to generate a listbox from a folder of pdfs that will generate the list and make them clickable to lauch each individual pdf from clicking the name of the file?
Generate listbox from file folder
Collapse
X
-
Code:--code to find pdf files and populate listbox --place in a button or onshow of page --Purge listbox of all previous data ListBox.DeleteItem("Name Of Listbox", LB_ALLITEMS); --find all pdf files in the folder tblPDF = File.Find("C:\\Path To Folder", "*.pdf", false, false, nil, nil); --ensure there was a result and continue if (tblPDF) then --loop to step through table adding items to listbox for i, v in tblPDF do --split file path so we can get the file name tblSplit = String.SplitPath(tblPDF[i]); --add filename as text and filepath as data ListBox.AddItem("Name Of Listbox", tblSplit.Filename, tblPDF[i]); end --no pdf files found else Dialog.Message("Notice", "No PDF files found", MB_OK); end
Code:--code for on click event of listbox --get selected item tblSelected = ListBox.GetSelected("Name Of Listbox"); --ensure there is a valid selection if (tblSelected) then --get data for selected item i.e the file path strFilePath = ListBox.GetItemData("Name Of Listbox", tblSelected[1]); --ensure no errors if strFilePath == "" then Dialog.Message("Notice", "No filepath found", MB_OK); --no error so open file else File.Open(strFilePath, "", SW_SHOWNORMAL); end --no listbox item selected else Dialog.Message("Notice", "No Item selected", MB_OK); end
-
-
Why i cant populate a hard drive folder...
I use this code and the Apz runs just fine... but i need to use this path "c:\\somedir\\otherdir" and when i use my hard drive i cant populate the files to the list box why is that any one can helpme a Byte.
myCategory = "PDFfiles"; --set the name to your own folder
bFound = Folder.DoesExist("AutoPlay\\Docs\\"..myCategory);
if bFound == true then
tFiles = File.Find("AutoPlay\\Docs\\"..myCategory, "*", false, false, nil, nil);
if tFiles then
ListBox.DeleteItem("ListBox1", -1); -- clears the previous choice
for i,sFilePath in pairs(tFiles) do
tFileParts = String.SplitPath(sFilePath); -- this breaks everypart of the filepath
sFileName = tFileParts.Filename; -- this one is the Filename only
sFileExtension = tFileParts.Extension; -- this one is File Extension only
sFullFileName = sFileName..sFileExtension; -- concatenate
ListBox.AddItem("ListBox1", sFileName, sFilePath); -- add to the ListBox
end
end
end
Comment
-
-
Greets Forum People... here is a Problemo any one can help...
I Just Bumb it...
About populate a listbox from hard drive using C:\\pathhere\\somefolder
Comment
-
-
Why you use a sub-path of the application ("AutoPlay\\Docs\\"..) if you instead need the path "c:\\somedir\\otherdir" ?
The code you posted works fine, but you are making confusion with file paths.We are slowly invading your planet to teach lazy humans to read the user manual.
But don't be scared: we are here to help.
Comment
-
-
my_docs_path = _DesktopFolder.."\\screens\\";
--or in your example my_docs_path = "c:\\somedir\\otherdir\\"
-- Search the user's My Documents folder for the text files.
search_resultsb = File.Find(my_docs_path, "*.txt", true, false, nil, nil);
for index, pathb in search_resultsb do
ListBox.AddItem("ListBox1", pathb, "")
end
else
end
Comment
-
Comment