George Stavrev
Posts: 17
Joined: 2011-06-30
|
Hi,
I am trying to add some javascript that will be loaded on all pages. I am having trouble getting it to load from a file included in the project. I am able to follow the existing project and other ideas such as http://www.add-in-express.com/forum/read.php?FID=10&TID=10837 but they only show how to do it if I have the text as a string.
What if I have say sample.js in my project or /Static/sample.js (inside a folder)? I tried using StreamReader but I can't point it to the right place. I know that my path is likely wrong, but how can I optain the path of where my file is? I tried Path.GetFullPath("Static/sample.js") but that leads to my C:/User/Desktop/Static/sample.js or something of that sort which doesn't host my raw file.
Any suggestions? I don't want to host such files online for now.
Thank you,
-George |
|
Sergey Grischenko
Add-in Express team
Posts: 7235
Joined: 2004-07-05
|
Hi George,
To get the path of the add-on assembly you can use the code below:
Uri uri = new Uri(this.GetType().Assembly.CodeBase);
string addonDir = Path.GetDirectoryName(uri.LocalPath);
string scriptDir = Path.Combine(addonDir, "Static"); |
|
George Stavrev
Posts: 17
Joined: 2011-06-30
|
Thanks Sergey! It worked very well for me. |
|