我的项目进展顺利。我最近刚刚决定在项目中的.txt资源中包含更新列表(“更新”文本文件“ Updates.txt”作为嵌入资源包含在项目的名称下)。我的应用程序没有崩溃,但是我想我将来可能要解决这个问题,因为在运行时将鼠标悬停在“ objstream”变量上时,我会在标题中看到消息。有人可以告诉我如何在下面修改我的代码吗?
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace MyApplication
{
/// <summary>
/// Interaction logic for About.xaml
/// </summary>
public partial class About : Window
{
public About()
{
InitializeComponent();
string version = null;
try
{
//// get deployment version
version = System.Deployment.Application.ApplicationDeployment.CurrentDeployment.CurrentVersion.ToString();
}
catch (System.Deployment.Application.InvalidDeploymentException)
{
//// you cannot read publish version when app isn't installed
//// (e.g. during debug)
version = "not installed";
}
Version.Text = "Version: " + version;
Assembly assembly = Assembly.GetExecutingAssembly();
Stream objStream = assembly.GetManifestResourceStream("MyApplication.Updates.txt");
StreamReader reader = new StreamReader(objStream);
string updateList = reader.ReadToEnd();
//reader.Close();
ChangesList.Text = updateList;
}
}
}