Compile Application with local files - wpf

So I have a word template that I am trying to populate within my wpf application. It works fine during development. However, when I try to edit the file after publishing/installing the application it no longer has the folder/files that were used in the development process.
What steps do I need to take to have files present after installation to manipulate, create, or delete files?

Right-click the file in VS Solution Explorer, then in file properties set Copy To Output Directory to Copy Always

Add that template as content in your solutions. You will find this from properties.

Related

VScode setting change. Is there a way? [duplicate]

I have used WebStorm from JetBrains for almost four years now. It's a fantastic IDE for many reasons, but one of the best features is that it saves versions of files outside of version control. So if you accidentally delete files or lose files before they are saved by your version control system, WebStorm has a copy of them and there are visual diff tools to use. This feature has saved me on more than one occasion.
For Visual Studio Code, is there some feature/plugin that will auto-save copies of files as they change? Will Visual Studio Code save the files to some central location, or perhaps in the .vscode folder in the local workspace?
The feature in WebStorm is available from Local History → Show History from a folder or file. Here is an article about it:
Using Local History for code changes tracking
The view looks like:
You can go to menu File and choose Auto Save.
You can enable auto save with these methods:
Check the Auto Save item in the File menu
Go to Settings, search for auto save, and select the auto save option (afterDelay)
Auto save description in Visual Studio Code documentation
Yes, Visual Studio Code can auto-save changes on files as you make changes. It also allows you set a delay for how long to wait before saving the file.
Here's a link that should help you with that.
Or a shortcut you can simply navigate to your Visual Studio Code settings, and add the following to your settings.json file.
{
...
"files.autoSave": "afterDelay",
"files.autoSaveDelay": 1000,
...
}
This will instruct your editor to autosave after a 1000 ms delay. You can set the autosave option to onFocusChange to autosave whenever you move your cursor away from the current text area.
There's a package called Local History that can be used to save a backup of your files outside version control.
You should check that out.
As of March 2022 (version 1.66), Visual Studio Code has a built-in feature called Local History that automatically creates commit-like versions of your files on every save.
It is enabled by default, but you can double check the setting workbench.localHistory.enabled to make sure it is enabled in your project.
From the reference:
Each local history entry contains the full contents of the file at the time the entry was created and in certain cases, can provide more semantic information (for example, indicate a refactoring).
From an entry you can:
Compare the changes to the local file or previous entry.
Restore the contents.
Delete or rename the entry.
The saved local versions are accessible from the Timeline section in the File Explorer tab.
Also, ensure you add .history to your .gitignore file, so Visual Studio Code doesn't track every change made to a single file as changes made to multiple files. This can be a problem and make your files changed so large even though it's a single file or a few files you made edits to.

Visual Studio 2017 Folders in Project

I am using Visual Studio 2017 to write some stuff in C. When I open a new project, I have some default filters and in "add" option for the project there's only filter and no folder/directory.
I want my project to have a folder structure, but can't add folders to the project in Visual Studio. Looking online I can only find solutions for adding an existing folder to a project and not adding a new one.
How can I add new folders to a Visual Studio C project?
How can I disable filters?
The way that I think of Visual Studio 2017 (earlier versions of the IDE as well) and its presentation of files in File View is as a kind of virtual file organizing system. File View allows you to logically organize files, presenting the actual file system in a more helpful manner.
The icons that look like folders in the File View are not really folders but are instead labels, called filters, which allow you to group your files however you like regardless of how they are physically stored in your persistent storage area such as a hard drive.
Filters are more flexible by not corresponding to the physical file folder hierarchy as they allow you to organize files that are all in a single folder into logical groups. Filters allow this to be done at a finer grain than is typically used by grouping files in folders. Filters also allow you to group files that are in multiple folders together into a single logical folder within File View.
However filters can be confusing because most of us are so accustomed to file folder hierarchies that the filter methodology can disconnect the logical file as represented in a Filter from the physical file location located in a folder.
My typical methods of adding files
Typically what I do is to create the physical folders through Windows or doing a clone of an existing Git or Subversion or VS Team Services source tree. With something new I may use the New Solution or New Project wizard to create my initial starting point and then organize and add files and folders physically through Windows and then go into the Visual Studio IDE to create the Filters and then Add existing files to the Filters. In some cases I will create sub-filters within a Filter in order to better organize the files within a physical Folder.
For new files I will just use the Add New Item menu option to add the item to the proper project. If you right click on a filter name, the new file will automatically be added to the filter. In some cases when I have added additional filters to the project to organize files, I will drag the newly created item to the proper filter and drop it there.
This drag and drop is not changing the physical location of the file but is changing its logical position by moving it from one filter to another. To move the file physically from one folder to another, I will usually do that with Windows. Just remember that if you do physically move a file with Windows you must also modify the file's entry in the Visual Studio 2017 filter to which it has been assigned, I usually do a Remove on the file followed by Add Existing Item and browse to its new location.
It appears you can not have the same file in multiple filters within the same project.
In some cases when I Add New item, I will change from the suggested folder displayed in the Add New Item dialog to a different folder using the Browse button. And if I need a different extension to the file then I will make that change as well, a common action when adding a new C source file to a project which requires changing the .cpp extension to .c.
You can also use the Browse button to navigate to a folder where you can then create a new folder if you like using the right click menu that displays when you do a right click in the displayed list of files and folders.
Unfortunately, the Add New Item dialog always wants to put a file into the project directory with all the other files. The Add Class wizard doesn't give you the opportunity to specify anything other than the default project folder. I have in some cases created C++ classes using the Visual Studio IDE, removed them from the project, moved the physical files to where I want them to be and then added them back to the project.
The filter approach seems to work well because the total solution is divided up into multiple projects and each project has its own physical folder. The multiple projects may correspond to particular DLLs or static libraries or other components that are used by the solution.
See also Can I configure Visual Studio to use real folders instead of filters in C++ projects?
Example screenshots of folder and filters
Here is a Windows folder view of a small project of the resources being used:
And this is how I have the filters set up. Normally the list of resource files can be quite long however I have created two sub-filters to logically separate out bitmap files from icon files though they both share the same physical resource folder.
Also the filter named PepIncludes corresponds with an actual physical folder named the same while the filters named "Header Files" and "Source Files" are groups of files that all reside in the same physical folder which is named the same as the project folder.
The following screen shot shows how filters can provide flexibility. I have a folder with include files, PepIncludes, and I have the same collection of files in two different projects within this Visual Studio 2017 solution. In a solution with 30 or 40 projects, this can make it a lot easier to manage files. For instance you can see that after modifying the file "ECR.h" the fact that it has been modified shows in both of the filter file listings (the small red check mark next to the name).

How to populate Isolated Storage for Windows Phone application

Is there a recommended way to initialize the data in Isolated Storage for Windows Phone 7 application before it is run for the first time? Right now the best solution I can think of is putting a flag in IsolatedStorageSettings and checking for its presence on in the application Launching event. If the flag is not present I initialize several objects in code and save them to Isolated Storage and set the flag so they are not set the next time the application is run. Is there a better way to do this? Should I add the objects in serialized state as some kind of resource or it is acceptable to initialize them in code? I expect that they would require like a thousand lines of code.
Well if you can create your files and add them to the project. And if you are sure that you will not be editing your files than just keep them like that. The files will go into your installation folder.
Or if you think that you are going to edit them and want to keep the changes saved, than copy them from the installation folder to the application storage folder.
Here is a link in which a database which was added as a reference to the project is copied from installation folder to storage folder of the app.
http://msdn.microsoft.com/en-us/library/hh286411(v=vs.92).aspx
Do the same for your files and everything will be fine.
The second part of your question. Well after this just check for one file/folder in the app storage folder and if it says yes it is there than do not copy your files from installation folder to application storage folder.
And if you are trying to make the files when the application launches than just add a check before the creation code is run. Where you will search for a file/folder existence. And if it exists do not run the file creation code.

eclipse CDT copying all project settings

It is possible to export settings from one project and import them in another.
However, it seems that only "include Paths" and "Symbols" can be moved to a new project this way.
Is there any reliable way to copy all settings? Particularly I would like to copy the linker settings for my embedded ARM project.
I do not want copy the settings manually, as this is something that will have to be done often by at bunch of people.
The easiest way I've discovered to duplicate the settings for a project is to use another workspace. It takes a few steps to set up but you should only need to do it once.
1. Start a 2nd copy of eclipse and select or create a new workspace.
2. Import your baseline code.
3. Rename the project to something generic like NewProject
4. If your project has files you don't want to be imported into new projects delete them. I find it helpful to keep a few (like main.cpp)
Now back to your original workspace.
1. File->Import->Existing Projects into Workspace Next button
2. Use Browse... to go to your newly created workspace and select NewProject.
3. Check the Copy projects into workspace checkbox.
4. If you have warnings about the project already existing try clicking the Refresh button and make sure you don't have a folder in the current workspace with the same name. [ You can delete a project but not remove it from the hard disk so you have to make sure the intended folder name is not in use. ]
5. Rename the project to your desired name.
6. Start coding...
All the toolchain settings, include paths and library paths should be intact. It seems like a lot of work, but once you do it once its not too bad (as long as you can keep duplicating that one project).
This can be done in simple steps. Useful if you do not want to create new workspaces.
Open the project in the workspace.
Click on project and copy.
On the project tab area, paste the project.
Eclipse asks for a name, rename it to a new project.
Click Ok.

Using update-able FlowDocument XAML files as my WPF help system

I'm putting together a simple help system for my WPF app using XAML FlowDcouments (just .xaml files, no code-behind). I've simply added them to my project with Build Action = Resource, and I can load and display them as required.
Now, I'm trying to make it a bit more flexible, in that after the installation of the app, I want the user to be able to download additional (or newer versions of the existing) FlowDocument XAML help files. Given this, I'm now wondering where the best place to store these files is. A few questions/ideas:
Can I leave them as resource files, and overwrite or add new files as required? I can't find a example of how to add/edit resources at runtime on SO/Google. Is it even possible?
If not, is there a recommended location to store these files? They should be available to all users, so they can't go into the User's directory - they would have to go in the program directory. Does the program directory have write-access (I remember having issues with that before)?
Any other ideas?
Thanks.
The resource files are embedded into the executable and therefore you cannot change them.
As for a common place to put your downloaded help files, you cannot store them in "Program Files" since you would need admin privileges to write there.
I suggest you put them into SpecialFolder.CommonApplicationData (see http://msdn.microsoft.com/en-us/library/system.environment.specialfolder(v=vs.80).aspx), which is defined as "The directory that serves as a common repository for application-specific data that is used by all users."

Resources