Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WebBrowser Folder View: New Folder & Parent Folder 1

Status
Not open for further replies.

CubeE101

Programmer
Nov 19, 2002
1,492
US
Using the WebBrowser to display a folder...

What is the best way to:

A) Create a new folder (via a button) like Right Click>New Folder...
This is generally displayed as a folder with a spark at the top-right corner...

B) Navigate to the Parent Folder (via a button) such as the old Dos command "CD .."
This is generally displayed as a folder with an up arrow...


For the first item, (A), I guess you could split the path with "\" and remove the last folder... but I would rather use some system folder method if available...

For the second item, (B), you could use MKDir, but that does not function the same as the standard windows method, where it creates a "New Folder" directory, optionally followed by a number if necessary... Plus you are placed in Edit Mode for the Name (F2)...


How would you implement standard windows methods in these 2 cases?

Again, I am using the WebBrowser to display the Files/Folders

Thanks In Advance,
-Josh

Visit My Site
PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
To navigate, you just need the ParentFolder property of the current Folder object

To create a new folder, if you don't like MKDIR, try invoking the Folder's NewFolder method. You will,however, have to add your own handling to deal with numbering and editing the folder name
 
I had just figured out ParentFolder property, coming from the direction of FSO...
Code:
    Temp = wbFolders.Document.Folder.ParentFolder.Self.Path
    If Temp <> "" Then wbFolders.Navigate2 Temp

And I assumed you could create a folder the same way... but, is there no way to have it generate the generic name for you...?

How would you edit it through the WebBrowser?
(At least make it envoke Edit Mode)

Could you give a quick example on this? (At least on key points)

Visit My Site
PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
OK... I think I got it...
Code:
    Temp = wbFolders.Document.Folder.Self.Path
    Temp = Temp & IIf(Right(Temp, 1) = "\", "", "\") & "New Folder"
    If Dir(Temp, vbDirectory) = "" Then
      wbFolders.Document.Folder.NewFolder "New Folder"
    Else
      Dim x As Integer
      x = 2
      Do While Dir(Temp & " (" & x & ")", vbDirectory) <> ""
        x = x + 1
      Loop
      wbFolders.Document.Folder.NewFolder "New Folder (" & x & ")"
    End If

Visit My Site
PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
So, then would you use InvokeVerb to invoke renaming?

If so how?

Visit My Site
PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
I think I got it this time...
Code:
    Dim FN As String
    Temp = wbFolders.Document.Folder.Self.Path
    Temp = Temp & IIf(Right(Temp, 1) = "\", "", "\")
    FN = "New Folder"
    If Dir(Temp & FN, vbDirectory) <> "" Then
      X = 2
      Do While Dir(Temp & FN & " (" & X & ")", vbDirectory) <> ""
        X = X + 1
      Loop
      FN = FN & " (" & X & ")"
    End If
    wbFolders.Document.Folder.NewFolder FN
    Do
      DoEvents
      For Each FI In wbFolders.Document.Folder.Items
        If FI.IsFolder And FI.Name = FN Then
          wbFolders.Document.SelectItem FI, 16
          FI.InvokeVerb "rename"
          Exit Do
        End If
      Next
    Loop

Is there a better way to do this???

Visit My Site
PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top