Windows Phone resource file

Source: Internet
Author: User

Some resource files are preset in the project more or less during application development. With development tools, we can add resource files to projects for use in programs.
I. BuildAction
1. There are three common statuses of BuildAction attributes: Content | Resource | None.
Files whose BuildAction attribute is set to Conten will be directly packaged in xap files as independent files.
Files whose BuildAction attribute is set to Resource will be embedded into the dll file in the xap package.
Files whose BuildAction property is set to None will not be stored in any form in the xap package
2. Select Content or Resource.
Microsoft explained that "Content" is better than "Resource. Because Windows Phone 7 optimizes the file and network stream, but the Memory stream does not. Set to the Content type. These files will exist in the xap package as independent files. If they are set to resource, they will be compiled into the dll. If these files are set as Resource, they need to be read and put into the file during playback, which reduces the performance. Therefore, if your program contains a large number of media files, it is better to set their BuildAction to "Content" for better performance.
  Ii. Read and Write resource files
1. resource files are read-only and cannot be written.
2. Read the resource file.

// Resource file path
String path = "/Res/test.txt ";
// Read the file content
String content = String. Empty;
// Resource Type File Processing
Try
{
StreamResourceInfo reader = Application. GetResourceStream (new Uri (path, UriKind. Relative ));
If (reader! = Null)
{
Using (StreamReader streamReader = new StreamReader (reader. Stream ))
{
Content = streamReader. ReadToEnd ();
}
}
}
Catch (Exception ex)
{
// Read failed
}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.