|
#1
|
||||
|
||||
|
Example : Populate a tree from Files in a Folder
The is an project i made on request.. It populates a tree object with files from a folder and when double click on a node it open the file
How to set it up Yourself : Create a tree object.. On Global Functions: Code:
function GetFolderContentsFromDialog()
folderbrowse = Dialog.FolderBrowse("Please select a folder:", _SourceDrive);
Zip = File.Find(folderbrowse, "*.rar", true, false, ShowSearchProgress, nil);
if Zip then
for i,v in Zip do
tbSplit = String.SplitPath(v);
name = tbSplit.Filename
tblNodeData = {};
tblNodeData.Text = name;
tblNodeData.Data = v;
Tree.InsertNode("Tree1", "3", tblNodeData);
end
end
end
function GetFolderContents()
Zip = File.Find(_SourceFolder, "*.rar", true, false, ShowSearchProgress, nil);
if Zip then
for i,v in Zip do
tbSplit = String.SplitPath(v);
name = tbSplit.Filename
tblNodeData = {};
tblNodeData.Text = name;
tblNodeData.Data = v;
Tree.InsertNode("Tree1", "3", tblNodeData);
end
end
end
function RunNodeFile()
sel_node = Tree.GetSelectedNode("Tree1");
node = Tree.GetNode("Tree1", sel_node);
node_data = node.Data
File.Open(node_data, "", SW_SHOWNORMAL);
end
1 Populate from a folder chosen with a dialog Code:
GetFolderContentsFromDialog() Code:
GetFolderContents() Code:
RunNodeFile() If you dont feel like copy and pasting the whole time then use my prebuild project |
|
#2
|
||||
|
||||
|
help?
I am pretty new at this and was playing with the code that you posted.
could you please show me how to change the File.Run to file.copy to a set location? thank you in advance, I am a novice coder and need all the help I can get. Mark |
|
#3
|
||||
|
||||
|
On global function, change the red line into the blue one
Code:
function GetFolderContentsFromDialog()
folderbrowse = Dialog.FolderBrowse("Please select a folder:", _SourceDrive);
Zip = File.Find(folderbrowse, "*.rar", true, false, ShowSearchProgress, nil);
if Zip then
for i,v in Zip do
tbSplit = String.SplitPath(v);
name = tbSplit.Filename
tblNodeData = {};
tblNodeData.Text = name;
tblNodeData.Data = v;
Tree.InsertNode("Tree1", "3", tblNodeData);
end
end
end
function GetFolderContents()
Zip = File.Find(_SourceFolder, "*.rar", true, false, ShowSearchProgress, nil);
if Zip then
for i,v in Zip do
tbSplit = String.SplitPath(v);
name = tbSplit.Filename
tblNodeData = {};
tblNodeData.Text = name;
tblNodeData.Data = v;
Tree.InsertNode("Tree1", "3", tblNodeData);
end
end
end
function RunNodeFile()
sel_node = Tree.GetSelectedNode("Tree1");
node = Tree.GetNode("Tree1", sel_node);
node_data = node.Data
File.Open(node_data, "", SW_SHOWNORMAL);
File.Copy(Node_Data, "C:\\MyDir\\", true, true, false, true, nil);
end
|
|
#4
|
||||
|
||||
|
Cool!
Thank you, I had tried that but had left something out!
I appreciate the help! Mark |
|
#5
|
|||
|
|||
|
Thanks for the code.
Any suggestions on how to enhance the GetFolderContents function to alphabetically sort the files that are retrieved? |
|
#6
|
||||
|
||||
|
you really shouldnt have to make it sort them. have the function load the files into a listbox or tree object and enable sort under object properties. you may also have to use set properties for your object in an on show or preload event. if you need any help let me know and i will try to get you a quick example
|
|
#7
|
|||
|
|||
|
Populate a tree from Files in a Folder
I am using the example project made by TristanD (..many many thanks if you are still around the Forum). The link is here
http://www.indigorose.com/forums/sho...node+open+file Now I need to make a couple of slight modifications to the code as follows: 1) Instead of the default folder (c:\root..) I need to define a specific folder under the \autoplay\docs\ folder 2) When the tree is populated I need to hide the file extension (i.e not show *.pdf etc) 3) When I press a button, I need to refresh the tree (for the same folder) without showing a dialog box. Perhaps I should mention that I am not using "rootfolder" input box or the "change" button inside the project Can anybody help...I am not a programmer so your assistance is greatly appreciated. Thanks Pakapaka |
|
#8
|
||||
|
||||
|
I don't think that thierry (Tristan) is still on the forum, he is programming in VB now... ah well, he made great examples ^^ i taught me programming in lua lol
|
|
#9
|
||||
|
||||
|
Quote:
Last edited by TristanD; 07-03-2008 at 05:35 AM. Reason: Me and My Typo's |
|
#10
|
|||
|
|||
|
Thanks Tristan...I will rewrite my question and repost it
Maybe you can help |
|
#11
|
||||
|
||||
|
Go Ahead, Repost
|
![]() |
«
Previous Thread
|
Next Thread
»
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Populate listbox with files in docs folder by modified date | wedgea09 | AutoPlay Media Studio 6.0 | 0 | 04-10-2006 08:02 AM |
| Unable to find software? | NigelLacey | Visual Patch 2.0 | 4 | 10-11-2005 11:35 AM |
| cookies | goukilord10 | AutoPlay Media Studio 5.0 | 6 | 05-20-2005 05:08 PM |
| INFO: Why Files are Renamed in the DATA Folder | Support | AutoPlay Media Studio 4.0 Examples | 0 | 10-24-2002 04:36 PM |
| INFO:The Files that are Built into the DATA Folder | Support | AutoPlay Media Studio 4.0 Examples | 0 | 10-03-2002 04:15 PM |
All times are GMT -6. The time now is 01:49 PM.









Linear Mode

