Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

How to get this type of window to select folder

How to get this type of window to select folder

Anonymous
Not applicable
2,113 Views
7 Replies
Message 1 of 8

How to get this type of window to select folder

Anonymous
Not applicable

you can get a window to select folder location via getSavePath

 

but I want to know how can we get the window which looks similar to what is in the screenshot?

 

Regards

0 Likes
2,114 Views
7 Replies
Replies (7)
Message 3 of 8

miauuuu
Collaborator
Collaborator
(
	local openFileRoll = dotNetObject "System.Windows.Forms.OpenFileDialog"		
	
	openFileRoll.title = "Select Files"
	openFileRoll.Multiselect = true
	openFileRoll.Filter = "MAX (*.max)|*.max"
	openFileRoll.FilterIndex = 1
	openFileRoll.RestoreDirectory = true
	
	result = openFileRoll.showDialog()
	result.ToString() 
	if (result.Equals result.OK) do 
	(
		print openFileRoll.fileNames
	)
)
https://miauu-maxscript.com/
Message 4 of 8

Anonymous
Not applicable

Thank you guys for the prompt response. Really appreciate it! 🙂

0 Likes
Message 5 of 8

Siger_
Enthusiast
Enthusiast

I think your image show FolderBrowserDialog 🙂

The method of use is very similar to that described above. Only will return the result not filenames, but the path to the directory.

Message 6 of 8

Anonymous
Not applicable

You're right. I did try FolderBrowserDialog but it displayed folder selection in tree view 😕

0 Likes
Message 7 of 8

Siger_
Enthusiast
Enthusiast

Yes, it is default limitations. Alternatively, you can write your own (not very complicated).

Some other options:

Use Microsoft.Office.Core.FileDialog //Inconvenient way

Use SaveFileDialog with some trick. C# example: 

 

// Prepare a dummy string
string zeroFileName = "Here";
var sfd = new SaveFileDialog();
sfd.FileName = zeroFileName;
if(sfd.ShowDialog() == DialogResult.OK)
{
    // Here's your save directory
    string savePath = Path.GetDirectoryName(sfd.FileName);
    // Do whatever
}

 Use WindowsAPICodePack. C# example:

var dlg = new Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog();
dlg.IsFolderPicker = true;

Another example: https://www.medo64.com/2011/12/openfolderdialog/

 

Also example: https://www.codeproject.com/Articles/15059/C-File-Browser

 

etc, etc, etc...

Message 8 of 8

Anonymous
Not applicable

thank you!!! 🙂

0 Likes