0

I'm writing some integration tests for some SQL scripts that live in a folder separate from the project. Since the setup of the machine I'm writing on the tests on differs from the machine they will be run on, I would like to include them as resource files rather than hard coding any paths. However the default behavior for adding an existing file as a resource file simply copies the file, which is not what I want in case any of the SQL scripts get updated.

Does anyone know the best way to get the resource file to actually reference the SQL scripts that are in a folder separate from the project, or to somehow copy them into the assembly at compile time so I don't have to load them via absolute/relative paths?

Edit: For clarity, I'm trying to get the resource file to act as a symlink to the original file at compile time. Adding an existing file to a resource in file in Visual Studio simply makes a copy of the file, which means any changes to the original are not propagated to the resource file.

Weebs
  • 435
  • 6
  • 17
  • http://stackoverflow.com/questions/3314140/how-to-read-embedded-resource-text-file – Daniel A. White Aug 19 '15 at 16:35
  • @DanielA.White Perhaps I'm misunderstanding what people in the thread are saying, but this doesn't seem to answer what I asked. I know how to access resource files, what I don't know is how to make it so that the resource file acts like a symlink to the original file rather than just creating a copy so if the original file is updated the resource file is also updated. – Weebs Aug 19 '15 at 16:43

1 Answers1

1

After asking on IRC, someone guided me to what I was looking for. You are able to add an existing file to a project as a link (there is an arrow on the Add box when in the file dialog), and set it's Build Action property to Embedded Resource

https://support.microsoft.com/en-us/kb/306234

Daniel posted a link on how to actually read an embedded resource:

How to read embedded resource text file

Community
  • 1
  • 1
Weebs
  • 435
  • 6
  • 17