Announcement

Collapse
No announcement yet.

Folder seach path root instead of full path

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Folder seach path root instead of full path

    Can someone please help me, building a portable exe. Search files folder called "search" wanted to search from where the build exe is (root) Instead of full path of the folder.

    Thanks


    Code:
    if e_Key == 13 then
    
    -- name the folder you wish to search
    -- sSearchFile = _DesktopFolder.."\\files"; -- This if you want the folder is in Desktop
    
    sSearchFile = "c:\\search\\"; -- folder path * drive *
    
    --name listbox as a vaiable
    LB = "LB_FileListStep1";
    
    --delete all existing entries in the listbox
    ListBox.DeleteItem(LB, -1);
    
    --get the text entered in the input box and store as a variable
    sFileSearch = Input.GetText("Input_FileSearch");
    
    	--if the input box was empty then notify the user
    
    	if sFileSearch== "" then
    	Dialog.Message("Notice", "PLEASE ENTER FILE NAME AND CLICK SEARCH  ", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
    Page.SetFocus("Input_FileSearch")
    Input.SetText("Input_FileSearch", "");
    	--input was not empty so perform search
    	else
    
    	--get the selected search type from the combobox item 
    	nSelectedSearch = ComboBox.GetSelected("Combo_Search");
    
    		--if searchtype is valid then continue
    		if nSelectedSearch ~=-1 then
    
    		--get the item data for the search type 1=wildcar 2=exact match
    		sSearchType = ComboBox.GetItemData("Combo_Search", nSelectedSearch);
    
    		--convert the search type to a number so we can compare it
    		nSearchType = String.ToNumber(sSearchType);
    			
    			--determine the search method and if its wildcard adjust the search file value
    			if nSearchType == 1 then sFileSearch = "*"..sFileSearch .."*.*";
    			end
    
    		--search for the file and store all results in a table	
    		tFiles = File.Find(sSearchFile, sFileSearch, true, false, nil, nil);
    
    			--if the table contains at least one value then continue
    			if tFiles then
    
    			--step through the table adding the file found results to the listbox
    			for i, FilesPath in pairs(tFiles) do
    				FileNameStart = String.ReverseFind(FilesPath, "\\", false) +1; --find the starting pos of the file name
    				FileNameLength = String.Length(FilesPath) - (FileNameStart -1); -- find the length of the cutoff 
    				FileName = "".. String.Mid(FilesPath, FileNameStart, FileNameLength); -- build the FileName
    				result = Folder.Find("files", "AutoPlay*", false, nil);
    
    				ListBox.AddItem(LB, FileName, FilesPath);			
    			end			
    
    		-- table contained no values hence file was not found notify user
    		else
    		Dialog.Message("SEARCH RESULT", "THERE ARE NO FILES IN THIS FOLDER Please Try Again  ");
    		end
    		Page.SetFocus("Input_FileSearch")
    		Input.SetText("Input_FileSearch", "");
    	end
    			end
    --restore search button
    Button.SetEnabled("Button_Search", true);
    end

  • #2
    Code:
    current_dir = Folder.GetCurrent( );

    Comment


    • #3
      Shrek, not working :(

      Comment


      • #4
        What does not work? It's not really clear what you are doing but try using:

        Code:
        Debug.ShowWindow ( boolean Show )
        then:

        Code:
        Debug.Print ( string Text )
        with string Text being your strings so you can see what is going on.

        Comment

        Working...
        X