Is there a standard directory browser dialogue in MFC that doesn't involve the user creating directories to specify ones that don't yet exist? - c++

I am working on the bootstrap application of an installer, and I have a dialogue that the user can open to select a different target directory from the given default. Currently, I'm using the CFolderDialog for that, but for the user to select a folder that doesn't yet exist, he has to create the folder first. Once the user has specified the directory, I want to be able to delete it so that, when I launch the installer, it can create the folder itself such that it gets flagged for uninstall. Also, if the user cancels out of my bootstrap application at any time, I don't want any unwanted folders lying around from when the user mucked around in the folder browser. The problem that I'm having is that, if I try to remove the folder that the user created while browsing for a new target folder, I get a sharing violation error. (I compare the directory's creation time with what the system time was at the time the dialogue was launched to make sure that it's OK for me to delete the directory.)
What I need is either a way to get around that sharing violation or another standard dialogue that doesn't involve the user having to create a new directory in order to specify it just because it doesn't yet exist.
Edit: When I originally posted this, I forgot that the folder dialogue that I'm using is actually the XFolder Dialog on the Code Project site. While it does let the user browse for a directory, it's not as intuitive as folder browser dialogues that I've seen in installers in the past. What I'd really want is something where the user can browse to the folder in which their new folder is to go and then simply append the new folder to the path in the dialogue's edit box without having to create the new folder.
Update As the XFolder dialogue is a customization of the standard Open File dialogue which uses a template, it does not work on Vista or newer OSs. Because of this, I must abandon use of this for something else. I'm still looking for a solution here. If someone can show me how to set the initial directory (as opposed to the root directory) when using SHBrowseForFolder(), I'd be willing to use that as my solution.

For your purpose, it would probably make sense to let the user select a base directory, e.g. "C:\Program Files" (creating one in the process if so desired) and install into a subdirectory of that (a name which you append to the selected path and let your installer create). Display the combined path after the user has selected the base. This way, the user doesn't feel like he has taken on responsibility for the directory you're creating, but still has a reasonable level of control over the destination.

I have never seen such a dialog window, neither in MFC nor in any other technology. I agree with Shog9, you should provide the user with a way to separate the selection of a base directory and the creation of directories.

You can use SHBrowseForFolder without specifying neither BIF_BROWSEINCLUDEFILES or BIF_NONEWFOLDERBUTTON.

Related

How do I add a new Razor Page Template to Visual Studio in ASP.NET Core 2.1?

I've got the Templates folder in my project hierarchy, and I've been modifying those pretty heavily to speed up my scaffolding workflow.
However, some of the objects in my database must persist forever. So, since they can't be deleted, they have a boolean activation state.
As such, I'd like to add two new actions to the CRUD workflow, Deactivate and Reactivate. I added the relevant templates to the Project\Templates\RazorPageGenerator folder, but when I click to add a new Razor Page, it still only shows the standard CRUD options.
I'm not sure where I need to register the new templates for them to be usable in the scaffolding operations...?
This is what I normally do and works all the time:
Right click the folder => Select Add > New File => Select Razor Page and modify the "Name" section to match my controller method name.
If it doesn't work for you, how about creating files "Deactivate.cshtml" and "Reactivate.cshtml" using normal means (Finder in MacOS, Window Explorer in Windows, or command prompt), copy them to your Project\Templates\RazorPageGenerator folder, and add them to your project by right click the folder in VS2017 => Select Add > Add Files from Folder
In .csprog change Project Sdk From Microsoft.NET.Sdk To Microsoft.NET.Sdk.Web

Media Library in Sitecore gone from production instance

In the authoring instance the media library is still there but at some point in the last 12 hours, the production media library folder simply vanished. The logs don't seem to be telling me anything, although I'm still looking.
I'm going to publish to resolve the issue, but I'm not sure how it happened in the first place. Are there any specific media library configuration items that might cause this to happen?
As it turns out, there were no languages for the item. Apparently, when you publish this way, it will delete the item from the target.
I do not know any specific media library configuration items that might cause this to happen. Perhaps is there anyway done a unpublish, what should not be allowed because it's a protected item.
But,
Check of the "media library" folder is still a protected Item.
On a protected item you can not change the Publish restrictions, and it can not delete or move.
If not, in the top navigation choose "Configure" and Protect Item from the Attributes buttons.
Normal the "media library" folder is a protected item.

Disabling/Enabling choose button of QFileDialog based on specific criteria

I have a QFileDialog prompting the user to select a directory. I am running QT version 4.3.5. I do not have the option of upgrading either.
I want the user to only be able to choose directories that contain two files with specific names. Something along the lines of disabling the "Choose" button if it does not contain these two specific files.
The searching I have done has only led me to ways of filtering the results, which is not what I want to do since the user needs to be able to browse all directories and all sub directories. If a directory is selected, then the check should be made to disable/enable the "Choose" button based on the above criteria.
Like I said, the only half close solutions I have found are explained in this thread QFileDialog for directories that have certain content
or this thread qfiledialog - Filtering Folders?
Both of those half solutions to my question require the use of QFileSystemModel, which wasn't introduced until QT 4.4.
How can I enable/disable the "Choose" button of a QFileDialog with QFileDialog::Directory set as the FileMode based on whether or not the selected/activated directory contains two specific files?
Thanks
You need to copy the file dialog's sources over to your project, modify the name of the class, and start tweaking it. That's the only way, unfortunately.

Contextual Menu to a Specific Folder

I have read how to add a contextual menu though registry to all files or files according the extension.
But how can I add a contextual menu that will work ONLY on files of a specific folder (for example on files of folder C:\contmenu)?
Can this be done?
Thanks a lot.
If you're implementing a context menu shell extension, you get the path of the item in your IShellExtInit::Initialize() method. Then you can decide depending on the path whether to add your entries to the context menu or not.
It's not possible to register an extension just for a specific path though.

How to get MS Word templates directory for another user?

I'm using the following code to get the path where Word stores its templates:
WordTemplatePath:=WordApp.Options.DefaultFilePath[$00000002];
The problem is that this returns the path for the actual, logged-in user.
Is there a way to get the path for another user of the same Windows instance?
I need it so my installer program can install the templates used by my program for other users as well.
That approach isn't going to work too well. Typically, users won't have access to other user's profile folders and the "templates" folder for each user is located in they're profile.
Generally, if you need a template installed for all users, it's best to put it in the word STARTUP folder, or possibly in the "WorkGroup Templates" folder.
Alternately, you could require admin rights for the install and then scan, but even then, its possible (though unlikely) that users could have changed the path to their templates folder and so you can hardwire it, you'd have to scan Word's registry settings for each user to do that job right. Not a pretty thing to contemplate.
Are you just updating you're own templates? or are you wanting to scan and modify all the templates that a user has created for themselves? If the latter, you might instead move that logic into your addin and make it a function that is called each time the user loads up (or maybe give them a button to press to force the scan).