对文件的BuildAction以content,resource两种方式的读取
在Demo项目中,新建文件夹Files,其中放置file1.txt, file2.txt
1. file1.txt的BuildAction为content:
Stream streamWithContent = Application.GetResourceStream(new Uri("Files/file1.txt", UriKind.Relative)).Stream;
String ssWithContent = new StreamReader(streamWithContent).ReadToEnd();
2. file2.txt的BuildAction为resource:
Stream streamWithResource = Application.GetResourceStream(new Uri("/Demo:component/Files/file2.txt", UriKind.Relative)).Stream;
String stringWithResource = new StreamReader(streamWithResource).ReadToEnd();