问题
I want to refer to a grammar file in my project(Rootfile->folder named grammar->the file named NumbersGrammar) I used this line of code but it tells me the 0x80070002 error (the system cannot find the file specified):
Uri Numbers = new Uri("ms-appx:///Grammar/NumbersGrammar.grxml" ,UriKind.Absolute);
回答1:
Make sure that the file exists in the specified location, and it's Build Action property is set to Content:
回答2:
Have you tried using appdata instead? In your case the full path would be
new Uri("appdata:/Grammar/NumbersGrammar.grxml");
Apparently although appdata and ms-appx both refer to the installation folder, they must be used for different situations.
Source: http://msdn.microsoft.com/en-us/library/windowsphone/develop/ff402541%28v=vs.105%29.aspx#BKMK_Installationfolder
来源:https://stackoverflow.com/questions/18839454/dont-know-how-to-refer-to-a-file-in-my-project-using-ms-appx-wp8