WP7 Application.getResourceStream retunring null every time

我们两清 提交于 2019-12-12 01:37:19

问题


Im trying to load a .txt file into a 2D array which i can do from a temp in isolated storage but our level builder writes to .txt files and moving them to isolated storage for each one is out of the question.

It is a windows phone game.

The text files Build action is set to content.

The Copy to output is set to Do Not Copy.

The file is in the base content folder.

        var ResrouceStream = Application.GetResourceStream(new Uri("grid_map;component/Data.txt", UriKind.Relative));
        if (ResrouceStream != null)
        {
          //do reading here
        }

I have a breakpoint on the if statment after it and when i check the var, it is still null and later on it throughs a null error in using (StreamReader Reader = new StreamReader(ResrouceStream .Stream))

because ResrouceStream is null.

Ive tried most ways or reading a .txt file but this seams the best way


回答1:


If you want to load the file with Application.GetResourceStream, you have to set its build action to Resource, not Content.



来源:https://stackoverflow.com/questions/14244179/wp7-application-getresourcestream-retunring-null-every-time

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!