C# 如何访问已作为内容添加到单独程序集中的文件?
我有一个项目,我将报告文件放入其中,现在我想在另一个项目中引用它们,我尝试了以下代码:C# 如何访问已作为内容添加到单独程序集中的文件?,c#,C#,我有一个项目,我将报告文件放入其中,现在我想在另一个项目中引用它们,我尝试了以下代码: StiReport.Load(new Uri("pack://application:,,,/GoldAccountingSystem.Reports;component/StimulReports/TBank.mrt") .LocalPath); 但我得到了这个错误: Could not find a part of the path 'E:\GoldAccou
StiReport.Load(new Uri("pack://application:,,,/GoldAccountingSystem.Reports;component/StimulReports/TBank.mrt")
.LocalPath);
但我得到了这个错误:
Could not find a part of the path 'E:\GoldAccountingSystem.Reports;component\StimulReports\TBank.mrt'.
GoldAccountingSystem.Reports
是报表的程序集名称,但我不知道为什么它会在E
中查找此程序集,尽管正确的地址是E:\Projects\GoldAccountingSystem\GoldAccountingSystem.Reports
我认为这是因为报告是作为内容而不是资源添加到项目中的。你知道吗?你应该试试相对Uri:
StiReport.Load(new Uri("/GoldAccountingSystem.Reports;component/StimulReports/TBank.mrt")
.LocalPath);
绝对Uri也应该起作用:
StiReport.Load(new Uri("pack://application:,,,/GoldAccountingSystem.Reports;component/StimulReports/TBank.mrt", UriKind.Absolute)
.LocalPath);
我已经试过了,但我发现了一个错误:
相对URI不支持此操作
谢谢,但这是同一件事,我在问题中写道。我知道,但逗号的数量没有任何变化。我更新了问题,请你再看一次。检查一下,我添加了UriKind.Absolute
谢谢,现在我知道问题是文件是作为内容而不是资源添加的,但我不知道如何修复它。无论如何,谢谢。