Including external folder in UWP visual studio project - c++

I have a UWP project in Visual Studio (2015, c++) and I want to include an external folder tree of assets (e.g. images) so that when I run it in the emulator those files are available (similarly, when I build a final package I want the files with the package). The files aren't fixed (i.e. I may add/remove files at a later time)
In a regular desktop application I would simply use a post-build step and do an xcopy on the folder into the target directory. This, however, does not work for the UWP build. When I run in the emulator nothing is there (or even in the target directory).
Is there some way to add a build step to copy files (retaining directory structure) or even better a way to add an external folder reference to the project?
I know I am not the only one that does this. Most results in searches are irrelevant, others aren't dynamic, or rely on the files to be within the project's directory tree.

Use AppxPackagePayload element in your .vcxproj file:
<AppxPackagePayload Include="PathToYourImage.jpg">
<TargetPath>SubfolderInPackage\FileName.jpg</TargetPath>
</AppxPackagePayload>
Unfortunately, you'll need to reference every file your want to copy separately. I don't know if there is a way to do it for a directory.

I have a UWP project in Visual Studio (2015, c++) and I want to include an external folder tree of assets (e.g. images) so that when I run it in the emulator those files are available (similarly, when I build a final package I want the files with the package). The files aren't fixed (i.e. I may add/remove files at a later time)
From your description, I think you want to mount an external folder for your uwp app. However, not all path can be accessed directly under current file access rules.
Access to other locations is available only through a broker process. This broker process runs with the user’s full privileges, and it can use these privileges on the app’s behalf for locations the app has requested via capabilities, locations requested by the user via file pickers, etc. The StorageItem encapsulates this brokerage procedure so the app doesn’t need to deal with it directly.
As Rob said that you can access to other locations with the user’s full privileges. For more you could refer to File access permissions official documentation.

Related

How to make a specific program run from the installed path only to avoid DLL hijacking

I have an executable which is linked with some dll files. To avoid DLL hijacking I am installing that application in a protected path (say C:\Program Files) where only the admin have "create" or "write" permissions.
Still some attacker can copy the entire installation folder to some other directory and able to craft a written function with the same name to perform malicious act such as deleting a file or modifying registry settings. The .DLL files will run on the same privileges as given to the running application.
I need to verify that my application is running only from the installed path..How can I make to possible using C++ ..
Look at GetModuleFileName to check where modules are located.

how to make stand-alone setup file of a mfc project including all data files

I have a project in VC++ MFC and works fine with the .mdb files. But just copying the project's .exe file on other system does not let the project work as it searches for the same path as mentioned in the code for the .mdb files and fails to find one. Also, apart from .mdb files, theres a need for certain .ocx files and io library suite to be registered in the system prior to the project's execution. How to overcome this problem?
You need to wrap up all the files into a package also known as installer. One of the most popular (and free) at the moment is Inno Setup. This will produce a single exe file that you will be deploying to users / other machines. You need to make sure that you include all the needed files, libraries etc in your setup.

Keeping source folder structure in windows runtime application assets

I am trying to create a Windows runtime application (in c++) and I want to store some "external" files in the application's Assets. I figured out there is a 'Content' flag which makes the file included in the package. However, if files are not located in the solution folder, all the files from all subfolders go directly into the Assets folder, which creates a huge mess. I want to keep my source folder structure. This works if the assets are located in the solution folder, but this is inconvenient for me.
On Android, you simply specify any assets folder location, and this folder is packaged as is. Can I do something like this on windows?
This post sort of gives answer to this question: Assets folder for Windows 8 Phone app.
However it feels like almost nobody including me have that drop-down option on the Add button (I am using VS2013 Ultimate Update 4).
So is there another solution? Can I for instance edit the visual studio project by hands?
Add as Link is only available for C# and VB Projects.

Qt specifying a location for certain application data

I am making an application in Qt. I have 2 directories, 1 for configurations, the other for program scripts.
I would like to have it say that when I build the project, it will place those directories in a certain directory.
For instance on linux:
/home/username/.project_name/configurations
/home/username/.project_name/scripts
This should also be cross platform, so on Windows and MacOS these files should be placed in the normal place where application data is stored.
Is there there a way to specify where these directories (and the files in them) should be placed? Is it an option in the project file? And which option ?
The qt resource system is used to store files within your application's executable.
You need to answer two questions:
Where do the files come from? Does your installer or package contain them, or are they in the executable proper and the application extracts them and saves them. Then the qt resource system is useful.
How to get the path you need to create your configuration directory. QDesktopServices::storageLocation(QDesktopServices::DataLocation) returns such a path in a cross-platform manner.

Creating a good directory structure

This might be a silly question but I am still learning. I have read several books on creating application and creating a good directory structure. When people talk about creating a directory structure, do they mean the folders you make within the solution explorer (folders you actually find inside of a .sln file) or do they mean setting up and creating folders that reside in the same folder as your .sln file or your compiled application (.exe). I figured the solution explorer folders are different from a typical windows folder cause the folders I create inside my .sln file are no where to be found on my windows system.
Visual Studio has a strange way of dealing with "folders" in solutions. A "Solution Folder" is not actually a physical folder, but more of a virtual folder managed by Visual Studio. Your files may end up in the root directoy, but VS will treat them as if they are in a "folder." This is configured and managed in the VS .sln or project file.
I'm not a fan of how this works in Visual Studio, I don't get why they don't just put files in physical folders. It's up to you whether you want to fight VS and try to keep your files in physical folders, or if you want to just let VS manage it, but ultimately, it really doesn't matter.
a typical directory struction will be like
bin (binaries)
Src
->.sln
->common
->.prj
->Project1
->.prj
->Project2
->.prj
Lib (3rd party lib's)
Doc (documentation)
Tools (3rd party tools)
Setup (setup projects)
Test (test cases)
With C++ in Visual Studio your solution directories need not match the filesystem, but they can.
Typically people refer to the directory structure as the filesystem layout of the project.
It's typical to have visual studio directories called headers and source, you wouldn't lay your project out like this on your filesystem though.
Visual Studio directories aren't just virtual folders though, they can contain filter rules so when you add a file to your project it will automatically get added to the correct filtered folder. They can also specify whether the folder should be under version control or not. And whether they should be parsed for auto complete or not.
Typically on filesystem I will create 1 folder per project and rarely create subfolders inside an individual project. But in the solution explorer I will create top level folders which I put projects into (For example: "Server Components" and "Client Components"), as well as in project folders to group things logically together (For example: Config, GUI, Controllers, ...) so I can find what i'm looking for faster.