• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    .NET

    Reply
    Valued Contributor
    Posts: 55
    Registered: ‎09-19-2006

    Easy way to ask for file and directory paths?

    167 Views, 5 Replies
    01-10-2008 01:35 PM
    Is there an easy way to ask the user for a directory or file, for saving or opening?

    Thanks.
    Please use plain text.
    *Norman Yuan

    Re: Easy way to ask for file and directory paths?

    01-10-2008 04:21 PM in reply to: namin
    With .NET framework (since you ask here), using OpenFile/SaveFileDialog and
    FolderBrowserDialog would be very easy.

    "namin" wrote in message news:5817613@discussion.autodesk.com...
    Is there an easy way to ask the user for a directory or file, for saving or
    opening?

    Thanks.
    Please use plain text.
    Distinguished Contributor
    Posts: 223
    Registered: ‎02-17-2006

    Re: Easy way to ask for file and directory paths?

    01-11-2008 01:56 PM in reply to: namin
    You could also use the Autodesk.AutoCAD.Windows namespace to access the internal open/save dialogs that match the Autocad application's GUI.

    The System.Windows.Forms namespace is a lot easier to use though...
    Please use plain text.
    Distinguished Contributor
    Posts: 139
    Registered: ‎08-21-2007

    Re: Easy way to ask for file and directory paths?

    05-09-2012 09:29 AM in reply to: namin

    so to add the control “OpenFileDialog" you drag the control from the tool box to a form "Form1.vb"....correct?

    now how do you access the method from a different class "myCommand.vb"

     

    example I have a form1.vb that has the control  “OpenFileDialog" named OpenFD.

    I then have myCommands,vb where I want to access OpenFD.

    how do I do that?

     

            Private Sub getfilename()
                openFD.InitialDirectory = "C:\"
                openFD.Title = "Open a Text File"
                openFD.Filter = "Text Files|*.txt"
                openFD.ShowDialog()
            End Sub

     

    Please use plain text.
    Valued Mentor
    Posts: 297
    Registered: ‎03-31-2005

    Re: Easy way to ask for file and directory paths?

    05-09-2012 10:52 AM in reply to: mfernandes

    In mycommands.vb you create an instance of your form - something like this:

     

    Friend Shared myForm As New form1

     

    Now mycommands can reference the contents of form1 through the instance "myForm", as in myForm.textbox (or whatever form tools you need to access).

     

    If you want the form1 tools to run methods in mycommands, the sub routines need to be declared as Public Shared.

     

    form1.vb can have something like this:

    Private Sub somebutton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlescmbFiles.Click

    mycommands.processformbuttonclick()

    EndSub

     

    mycommands should have Public Shared Sub processformbuttonclick()

     

    This is a good example - it refers to palettes and containers but containers behaviour is very similar to forms.

    http://forums.autodesk.com/autodesk/attachments/autodesk/152/26712/1/CP205-2_Mike_Tuersley.pdf

     

    Please use plain text.
    Distinguished Contributor
    Posts: 139
    Registered: ‎08-21-2007

    Re: Easy way to ask for file and directory paths?

    05-09-2012 11:59 AM in reply to: fieldguy

    thanks.

    There is some interesting stuff in the paper by

    Mike Tuersley AU2007 that I need to go through

     

    thanks again

    Please use plain text.