views:

103

answers:

1

In a WPF application, I load in xaml files with the xamlreader by finding the current directory like this:

public static string GetApplicationDirectory()
{
    return System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
}

so I can read in a .xaml file by getting its absolute path like this:

string pathAndFileName = GetApplicationDirectory() + @"\Layouts\LayoutMain.xaml";

in Silverlight the GetDirectoryName(...) method gives me a MethodAccessException.

How to can I read in these .xaml resource dictionary files that are located relative to the .xap file in Silverlight?

I can imagine I could have a directory under where my .xap file is placed called "Layout" with my .xaml files in it that I could read, but what would be the Silverlight command to read in this .txt file relative to the URI at which the .xap file happens to be placed?

+1  A: 

I wouldn't imagine you could as you're limited to what's in isolated storage. Unless you download those and save them in isolated storage in your app after it has started. I download .xap files after starting my SL app using WCF, as "plug-ins". Maybe that would work for you, instead?

Program.X