开发者

Application.GetContentStream returns null for content Uri

开发者 https://www.devze.com 2023-03-03 18:54 出处:网络
I have file \"sam开发者_StackOverflowple.xml\" in my project set as content. I am running this code:

I have file "sam开发者_StackOverflowple.xml" in my project set as content.

I am running this code:

  Uri uri = new Uri("/sample.xml", UriKind.Relative);
  StreamResourceInfo contentStream = Application.GetContentStream(uri);

Why it returns null contentStream?


You must set file's Build Action as Content, and Copy To Output Directory to Copy Always or Copy if newer.

Application.GetContentStream returns null for content Uri


It means probably that it does not find the file. Is the path correct?.

Return Value

Type: System.Windows.Resources.StreamResourceInfo

A StreamResourceInfo that contains a content data file that is located at the specified Uri. If a loose resource is not found, null is returned.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号