如何访问 Silverlight .xap 文件下文件夹中相对位置的文本文件?

发布于 2024-08-19 16:02:24 字数 806 浏览 4 评论 0原文

WPF应用程序中,我通过查找当前目录,使用xamlreader加载xaml文件,如下所示:

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

这样我就可以读入.xaml 文件,通过获取它的绝对路径,如下所示:

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

在 Silverlight 中,GetDirectoryName(...) 方法给我一个 MethodAccessException

如何读取这些位于 Silverlight 中相对于 .xap 文件的 .xaml 资源字典文件?

我可以想象我的 .xap 文件下可能有一个目录 被放置为“Layout”,其中包含我可以读取的 .xaml 文件,但是在此 .txt 文件中读取的 Silverlight 命令 相对于 URI 是什么? strong> .xap 文件恰好放置在哪个位置?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

爱已欠费 2024-08-26 16:02:25

我无法想象你可以,因为你仅限于独立存储中的内容。除非您在应用程序启动后下载这些并将它们保存在应用程序的独立存储中。我使用 WCF 启动 SL 应用程序后下载 .xap 文件作为“插件”。也许这对你有用?

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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文