.NET

.NET

Reply
Valued Contributor
namin
Posts: 55
Registered: ‎09-19-2006
Message 1 of 6 (214 Views)

Easy way to ask for file and directory paths?

214 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.
*Norman Yuan
Message 2 of 6 (214 Views)

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.
Distinguished Contributor
jbooth
Posts: 223
Registered: ‎02-17-2006
Message 3 of 6 (214 Views)

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...
Mentor
mfernandes
Posts: 208
Registered: ‎08-21-2007
Message 4 of 6 (146 Views)

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

 

Valued Mentor
fieldguy
Posts: 382
Registered: ‎03-31-2005
Message 5 of 6 (137 Views)

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

 

Mentor
mfernandes
Posts: 208
Registered: ‎08-21-2007
Message 6 of 6 (134 Views)

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

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.