How to read a resource file within a Portable Class Library?

后端 未结 8 1740
夕颜
夕颜 2020-12-05 03:26

I have a Portable Library which I am using for a Windows Phone application. In that same Portable Library, I have a couple of content files (Build Action = Cont

8条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-05 03:46

    if you have added files as resources, check your .Designer.cs, there will be a property for each resource. you can access from that.

    here is the sample auto generate property for dat file resources

       internal static byte[] MyDatFile {
            get {
                object obj = ResourceManager.GetObject("MyDatFile", resourceCulture);
                return ((byte[])(obj));
            }
    

    you can read the dat file as

        System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding();
        var str = enc.GetString(Resource1.MyDatFile);
    

提交回复
热议问题