Common Dialog OpenFile - Default Folder To Browse?

Jonathan2708
Member Posts: 552
Hi,
I'm using Codeunit 412 Common Dialog Management to prompt the user for a file. My question is can you set the OpenFile function to popup the window in a specific folder via code? You can give it a default filename, but can't see how to set a default folder.
If not is there a workaround, maybe another function to call first to set the users' default folder?
Any help appreciated,
Jonathan
I'm using Codeunit 412 Common Dialog Management to prompt the user for a file. My question is can you set the OpenFile function to popup the window in a specific folder via code? You can give it a default filename, but can't see how to set a default folder.
If not is there a workaround, maybe another function to call first to set the users' default folder?
Any help appreciated,
Jonathan
0
Answers
-
In 412 you'll see:
CommonDialogControl.InitDir := DefaultFileName;
I guess it takes the path of the file you pass as a parameter.
Either pass your parameter differently or
copy the function as OpenFile2, add a parameter defDir and change the line to :
CommonDialogControl.InitDir := defDir;
Try it to see if it works...0 -
Hi,
Thanks for the reply but already tried that. It simply uses the parameter as a default filename, not folder, and if you specify a backslash e.g. 'C:\WINDOWS\' then you get an error message.
Jonathan0 -
I tried it like this:
I Copied OpenFile to new function OpenFile2.
I added one more parameter defdir (text 30);
I found the line:CommonDialogControl.InitDir := DefaultFileName;
and changed it to:CommonDialogControl.InitDir := defdir;
Then to call the function I do the following:cu412.OpenFile2('Open','',0,'',0,'C:\program files\adobe');
Did you try it like this? When I run it it opens folder C:\program files\adobe with a blank filename.0 -
Thanks, I've sussed it. The default folder only works if you set the default filename to blank ''.
Thanks for your help,
Jonathan0 -
You're welcome.0
-
Jonathan2708 wrote:The default folder only works if you set the default filename to blank
I tried it and it also works if you pass as a filename 'file.txt' for example, along with the path parameter...0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions