如何使用嵌入式资源(文本文件)StreamReader
并将其作为字符串返回?我当前的脚本使用Windows窗体和文本框,允许用户查找和替换未嵌入的文本文件中的文本.
private void button1_Click(object sender, EventArgs e)
{
StringCollection strValuesToSearch = new StringCollection();
strValuesToSearch.Add("Apple");
string stringToReplace;
stringToReplace = textBox1.Text;
StreamReader FileReader = new StreamReader(@"C:\MyFile.txt");
string FileContents;
FileContents = FileReader.ReadToEnd();
FileReader.Close();
foreach (string s in strValuesToSearch)
{
if (FileContents.Contains(s))
FileContents = FileContents.Replace(s, stringToReplace);
}
StreamWriter FileWriter = new StreamWriter(@"MyFile.txt");
FileWriter.Write(FileContents);
FileWriter.Close();
}
Run Code Online (Sandbox Code Playgroud) 我有一个VS2008我想将目录中的某些文件复制到我的/bin/
文件夹中.我已将文件(位于/common/browserhawk/
)设置为"复制到输出目录".但是,它也会复制文件夹结构:文件被复制到/bin/common/browserhawk/
如何将这些文件复制到只是/bin/
?我不想将它们存储在网站的根目录中以使它们正确复制.