积极答复者
WPF 和 WinForm 应用程序的解决方案目录下的文件夹里面的文件怎么才能提取加载?

问题
-
WPF 和 WinForm 应用程序的解决方案目录下的文件夹里面的文件怎么才能提取加载?
获取内容?
提取的文件Stream流怎么加载加载?
System.IO.FileStream stream = new System.IO.FileStream("/Content/Info.xaml", FileMode.Open, System.IO.FileAccess.Read); Viewport3D view = (Viewport3D)System.Windows.Markup.XamlReader.Load(stream); Page page = new Page(); page.Content = view; MainFrame.Content = page;
FileStream("/Content/Info.xaml" 这个代码中路径无效!
Final Fantasy
- 已编辑 Neoo 2014年10月26日 10:20
答案
-
System.Uri u = new System.Uri("/Content/Info.xaml", System.UriKind.Relative); Page window = (Page )Application.LoadComponent(u); MainFrame.Content = window;
System.Uri ux = new System.Uri("/Content/XMLFile1.xml", System.UriKind.Relative); Stream xml = Application.GetResourceStream(ux).Stream; TextReader txt = new StreamReader(xml); string sttttt= txt.ReadToEnd();
全部回复
-
使用Application.StartUp+"/Content/Info.xaml"路径看看。
注意引入命名空间:System.Windows.Forms.
ASP.NET Forum
Other Discussion Forums
FreeRice Donate
Issues to report
Free Tech Books Search and Download- 已编辑 ThankfulHeartModerator 2014年10月26日 7:51
-
只要你保证你的程序(exe)文件所在的目录下有一个Content文件夹,里边有这个xaml文件即可。
ASP.NET Forum
Other Discussion Forums
FreeRice Donate
Issues to report
Free Tech Books Search and Download -
System.Uri u = new System.Uri("/Content/Info.xaml", System.UriKind.Relative); Page window = (Page )Application.LoadComponent(u); MainFrame.Content = window;
System.Uri ux = new System.Uri("/Content/XMLFile1.xml", System.UriKind.Relative); Stream xml = Application.GetResourceStream(ux).Stream; TextReader txt = new StreamReader(xml); string sttttt= txt.ReadToEnd();