相关疑难解决方法(0)

如何读取嵌入式资源文本文件

如何使用嵌入式资源(文本文件)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)

.net streamreader embedded-resource

643
推荐指数
12
解决办法
53万
查看次数

复制到输出目录复制文件夹结构,但只想复制文件

我有一个VS2008我想将目录中的某些文件复制到我的/bin/文件夹中.我已将文件(位于/common/browserhawk/)设置为"复制到输出目录".但是,它也会复制文件夹结构:文件被复制到/bin/common/browserhawk/

如何将这些文件复制到只是/bin/?我不想将它们存储在网站的根目录中以使它们正确复制.

相关问题:Visual Studio在编译后将.dll和.pdb添加到项目中

msbuild visual-studio-2008

87
推荐指数
6
解决办法
5万
查看次数