【发布时间】:2014-02-11 18:55:00
【问题描述】:
我正在使用 C# 中的 Winforms。我有以下 Html 文件。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content="HTML Tidy for Windows (vers 25 March 2009), see www.w3.org" />
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
<link rel="stylesheet" type="text/css" href="styles.css" />
<title></title>
</head>
<body>
<p><b>Chapter 1</b></p>
</body>
</html>
我想用"<link rel="stylesheet" type="text/css" href=""+ htmlFile +"" />" 替换<link rel="stylesheet" type="text/css" href="styles.css" />
我已经尝试了以下代码,但它不起作用
string outpageFile = File.ReadAllText(StaticClass.outpage);
string htmlFile= StaticClass.ZipFilePath + "\\OEBPS\\styles.css";
outpageFile = outpageFile.Replace("<link rel='stylesheet' type='text/css' href='styles.css' />", "<link rel='stylesheet' type='text/css' href='"+ htmlFile +"' />");
File.WriteAllText(StaticClass.outpage, outpageFile);
但它不起作用。主要问题出现在正在使用的双引号中。那怎么办呢??
【问题讨论】: