How to properly add resources to my project

  • Thread starter Thread starter DZ Creator
  • Start date Start date
D

DZ Creator

Guest
Hello friends!


I am currently developing my first app and I am looking for some help. I am using the Microsoft Visual Studio and C# as my programming language.


Here is how the app is supposed to work: Users can make different selections using combo boxes and then click the 'Search' button to get what they're looking for. Depending on their choices, the program is supposed to open a corresponding MS Word file with the details. To do this, I am using the NuGet package docX (by Xceed). This lets the app manipulate MS Word files (I.e. find the correct Word file, find the correct Heading in that file, create a new Word document, paste the required information into the new file and display it for the user).


This works fine when the program is ran from the Microsoft Visual Studio, where it was created. As soon as I publish my app and try to run it independently, I get an error message saying that the Word file could not be found.


I understand why I am getting this error. When I set it up, my app is unable to run code such as:

if (File.Exists(@"C:\Users\Dusan\source\repos\DZ Search\DZ Search\bin\Debug\procedura.docx"))
{

File.Delete(@"C:\Users\Dusan\source\repos\DZ Search\DZ Search\bin\Debug\procedura.docx");
}

System.Diagnostics.Process.Start(@"C:\Users\Dusan\source\repos\DZ Search\DZ Search\bin\Debug\procedura.docx");


This is my first question: How can I set a specific file path where the app will retrieve the document from? Ideally, it should be in the app's installation directory, so it can work on anyone's PC.


I would also like the docX package to work the same way. So far, it can only find/create documents that are located directly in the project folder. Is there any way to specify where the docX package will look for files, or where a new file will be created?


What I am trying to ask, how can I set up a database my program can reference to get all of the resources?


I really hope this makes sense to anyone reading this, because this is my very first project and I don't have a lot of experience using Microsoft Visual or C#.

Continue reading...
 
Back
Top