Re[2]: How to make Browse Folder Dialog

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



http://cwashington.netreach.net/depo/default.asp?topic=repository&move=next&ScriptType=vbscript&SubType=Misc

Script:

'********************************************************
' FolderSelectDialog.vbs
' Alan Kaplan alan at akaplan dot com 12-15-2005
' after getting tired of reading it will not work...
' Based in part on FileSelectDialog.vbs by Gunter Born
' Kaplan added handling of special folders
' Tested okay with XP and 2000
' Uses the shell browseforfolder method to select a folder
'********************************************************
Option Explicit

' Flags for the options parameter
Const BIF_returnonlyfsdirs = &H0001    'Don't want no steenkin' filenames
Const BIF_ShowAllObjects      = &H0008    'ReturnFSAncestors. This will give you typical root view
                                        'XP has My Computer, My Network Places not seen on 2000
Const BIF_editbox = &H0010    'Show active selection, allows manual input

Dim wshShell
'Wscript object
Set wshShell = WScript.CreateObject("WScript.Shell")

'=== Example ===
Dim strFolder

StrFolder = BrowseForFolder("Choose a folder, then click OK:", _
    BIF_returnonlyfsdirs + BIF_editbox + BIF_ShowAllObjects,"")

If Len(strFolder)>0 Then
    MsgBox strFolder,vbOKOnly, "Selected Folder"
End If 

'= End Example ===

Function BrowseForFolder(title, flag, dir)
    ' title = Text shown in the dialog box
    ' flag = values controlling BrowseForFolder behavior
    ' dir = Initial directory (can be ""). 
    '    dir most useful when not using BIF_ShowAllObjects 
    On Error Resume Next
Dim oShell, oItem, strSelection

' Create Shell object.
Set oShell = WScript.CreateObject("Shell.Application")

' Invoke Browse For Folder dialog box.
Set oItem = oShell.BrowseForFolder(&H0, title, flag, dir)
        strSelection = oItem.Title 
        If Err <> 0 Then 'cancelled
Set oShell = Nothing
Set oItem = Nothing
Exit Function
End If
    
' If colon found then get drive letter from the title. No array
If InStr(strSelection, ":") Then 
BrowseForFolder = mid(strSelection,InStr(strSelection, ":")-1, 2)
    Else
    'Handle all other special cases where path not returned 
        Select Case strSelection
            Case "Desktop"
                BrowseForFolder = wshShell.SpecialFolders("Desktop")
            Case "My Documents"
                BrowseForFolder = wshShell.SpecialFolders("MyDocuments")
            Case "My Computer"
                MsgBox "Invalid selection",vbCritical + vbOKOnly,"Error"
                WScript.Quit
            Case "My Network Places"
                MsgBox "Invalid selection",vbCritical + vbOKOnly,"Error"
                WScript.Quit
            Case Else        
             ' Finally try to retrieve the full path a la Born
             BrowseForFolder = oItem.ParentFolder.ParseName(oItem.Title).Path
        End Select
    End If
    
    'Cleanup 
Set oShell = Nothing
Set oItem = Nothing    

    'make sure they all end in \
If Right(browseForFolder,1)<> "\" Then
    browseforfolder = browseforfolder & "\"
End If

    'Alternate make sure they all end without \
' If Right(browseForFolder,1) = "\" Then
'     browseforfolder = left(BrowseForFolder,Len(BrowseForFolder)-1)
' End If

    On Error GoTo 0
End Function

Wednesday, January 24, 2007, 9:51:24 AM, you wrote:


> Hello,
> Just a minute. I know the php script will run on server. Suppose i m working
> on server machine and i need to make a project for myself. The machine is
> only one and same. Also there are a lot of file and directory methods
> available in PHP, Whats that? Actually i want to show the files of selected
> folder on screen.
> Thanks...


> Travis Doherty-2 wrote:
>> 
>> Borge Holen wrote:
>> 
>>>On Wednesday 24 January 2007 07:32, Travis Doherty wrote:
>>>  
>>>
>>>>Aslam Bari wrote:
>>>>    
>>>>
>>>>>Dear All,
>>>>>I m new in this Forum. I m making a project in which i need to show user
> a
>>>>>Browse Folder Dialog Box, In which he can select a folder and after this
> i
>>>>>will do some manipulation on that folder's content. So the problem is
> that
>>>>>i could not found any sample on Web , how to show "Folder Dialog" in any
>>>>>way (HTML, JavaScript, PHP etc). Plz has anybody some idea how to do
> some
>>>>>work around this.
>>>>>
>>>>>Thanks...
>>>>>      
>>>>>
>>>>PHP won't let you edit files on your users' computer.  Ever.
>>>>
>>>>Maybe it would be worth your time to look into a different language to
>>>>do whatever it is you want to do, something like Visual Basic might suit
>>>>you well (last time I used it there was a control that would popup the
>>>>standard windows 'Select Folder' dialog.)
>>>>
>>>>Travis Doherty
>>>>    
>>>>
>>>
>>>Ouch, this is close to swearing in the church...
>>>
>>>  
>>>
>> :p  I suppose it is.  Use the right tool for the job right?  PHP on a
>> server won't ever let the OP manipulate the content of a folder on his
>> users computer.
>> 
>> T
>> 
>> -- 
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>> 
>> 
>> 

> -- 
> View this message in context:
> http://www.nabble.com/How-to-make-Browse-Folder-Dialog-tf3079100.html#a8555797
> Sent from the PHP - General mailing list archive at Nabble.com.


--

http://www.freenet.am/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux