Hi Katrin,I think I may have it working: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.On the properties for "Test.txt" file I set "Copy Always", but I left the Build Action as "Content".Then I used this code to access the file:First, a static property to get the path to the Add-in DLL:
// From StackOverflow
static public string AssemblyDirectory
{
get
{
string codeBase = System.Reflection.Assembly.GetExecutingAssembly().CodeBase;
UriBuilder uri = new UriBuilder(codeBase);
string path = Uri.UnescapeDataString(uri.Path);
return System.IO.Path.GetDirectoryName(path);
}
}
Then this code in OnClick() for a button add-in:
string fileName = AssemblyDirectory + "/Test/Test.txt";
StreamReader inFile = new StreamReader(new FileStream(fileName,
FileMode.Open, FileAccess.Read));
string msg = "";
try
{
while (inFile.Peek() != -1)
{
msg += inFile.ReadLine() + "\n";
}
}
finally
{
inFile.Close();
}
MessageBox.Show(msg);
It's not heavily tested or optimized, but it should get you started.-Jeff