<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Add-In: embedded Files and use it's path in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/add-in-embedded-files-and-use-it-s-path/m-p/557263#M15059</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;okay. I figured out to copy my file into the addin itself.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;(Just works how I described it wouldn't, but a day later, it just did, what it was supposed to do).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But I still have problems to gain access to that file when my solution is running.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Does anyone have a clue?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks a lot.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 17 Nov 2010 13:49:37 GMT</pubDate>
    <dc:creator>KatrinWalz</dc:creator>
    <dc:date>2010-11-17T13:49:37Z</dc:date>
    <item>
      <title>Add-In: embedded Files and use it's path</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/add-in-embedded-files-and-use-it-s-path/m-p/557262#M15058</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I am trying to export some metadata.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;For this I want to use following code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;xml.SaveAsFile(path_xslt, "", false, ref path);&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;path_xslt includes the path to the xslt-File. I want this File to be included in the Add-In.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I found the following in the concepts for Add-Ins:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;You can create additional folders and files under the Install folder. This is useful in cases where you want to ship data as part of your add-in. If you're adding data through your Visual Studio project, set the Copy to Output Directory property to the Copy always setting as shown in the following screen shot:&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So I set the Copy to Output Directory property to "Copy always" and the Build Action to "AddInContent".&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am not really sure whether this is right. :confused:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Which is the correct way to embed my file? And on which path can I access that file?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Nov 2010 07:45:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/add-in-embedded-files-and-use-it-s-path/m-p/557262#M15058</guid>
      <dc:creator>KatrinWalz</dc:creator>
      <dc:date>2010-11-16T07:45:05Z</dc:date>
    </item>
    <item>
      <title>Re: Add-In: embedded Files and use it's path</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/add-in-embedded-files-and-use-it-s-path/m-p/557263#M15059</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;okay. I figured out to copy my file into the addin itself.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;(Just works how I described it wouldn't, but a day later, it just did, what it was supposed to do).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But I still have problems to gain access to that file when my solution is running.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Does anyone have a clue?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks a lot.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Nov 2010 13:49:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/add-in-embedded-files-and-use-it-s-path/m-p/557263#M15059</guid>
      <dc:creator>KatrinWalz</dc:creator>
      <dc:date>2010-11-17T13:49:37Z</dc:date>
    </item>
    <item>
      <title>Re: Add-In: embedded Files and use it's path</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/add-in-embedded-files-and-use-it-s-path/m-p/557264#M15060</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Katrin,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think I may have it working:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In C# 2008 Solution Explorer I added a folder named "Test" and then a text file within it named "Text.txt" with just some dummy text.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;On the properties for "Test.txt" file I set "Copy Always", but I left the Build Action as "Content".&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Then I used this code to access the file:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;First, a static property to get the path to the Add-in DLL:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
// From StackOverflow
static public string AssemblyDirectory
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; get
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; string codeBase = System.Reflection.Assembly.GetExecutingAssembly().CodeBase;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; UriBuilder uri = new UriBuilder(codeBase);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; string path = Uri.UnescapeDataString(uri.Path);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return System.IO.Path.GetDirectoryName(path);
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
} &lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Then this code in OnClick() for a button add-in:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
string fileName = AssemblyDirectory + "/Test/Test.txt";

StreamReader inFile = new StreamReader(new FileStream(fileName,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FileMode.Open, FileAccess.Read));

string msg = "";

try
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; while (inFile.Peek() != -1)
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; msg += inFile.ReadLine() + "\n";
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
}
finally
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; inFile.Close();
}

MessageBox.Show(msg);
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It's not heavily tested or optimized, but it should get you started.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;-Jeff&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:03:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/add-in-embedded-files-and-use-it-s-path/m-p/557264#M15060</guid>
      <dc:creator>JeffreyHamblin</dc:creator>
      <dc:date>2021-12-12T00:03:41Z</dc:date>
    </item>
    <item>
      <title>Re: Add-In: embedded Files and use it's path</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/add-in-embedded-files-and-use-it-s-path/m-p/557265#M15061</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Saved my day, thanks.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Fernando&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 03 Jul 2011 21:50:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/add-in-embedded-files-and-use-it-s-path/m-p/557265#M15061</guid>
      <dc:creator>FernandoRangel</dc:creator>
      <dc:date>2011-07-03T21:50:55Z</dc:date>
    </item>
    <item>
      <title>Re: Add-In: embedded Files and use it's path</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/add-in-embedded-files-and-use-it-s-path/m-p/557266#M15062</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;For anyone seeking to do this in VB, this code (slightly different) works for me:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;Dim codeBase As String = System.Reflection.Assembly.GetExecutingAssembly.CodeBase
Dim uriBuilder As UriBuilder = New UriBuilder(codeBase)
Dim path As String = Uri.UnescapeDataString(uriBuilder.Path)
Return System.IO.Path.GetDirectoryName(path)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I can then create the full path to my file by appending a backslash and my file name.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:03:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/add-in-embedded-files-and-use-it-s-path/m-p/557266#M15062</guid>
      <dc:creator>LesleyBross</dc:creator>
      <dc:date>2021-12-12T00:03:44Z</dc:date>
    </item>
  </channel>
</rss>

