我试图在不更改其名称的情况下编辑txt文件,但我对下一步的工作感到困惑。
这是我拥有的:
private void btnApply_Click(object sender, EventArgs e)
{
StreamWriter sw = new StreamWriter(richTbWrite.Text);
sw.WriteLine(richTbWrite.Text);
sw.Close();
this.Close();
}
答案 0 :(得分:1)
void main() {
String str = 'HelloWorld';
var words = str.split(new RegExp(r"(?<=[a-z])(?=[A-Z])"));
print(words);
}
答案 1 :(得分:1)
我认为richTbWrite是RichText框。首先,我将打开文件并阅读内容,并将其分配给富文本框。然后将富文本框的文件内容再次保存到同一文件。
private void Form1_Load(object sender, EventArgs e)
{
string fileName = @"C:\Users\Public\TestFolder\WriteText.txt";
string text = System.IO.File.ReadAllText(fileName);
richTbWrite.Text = text;
}
private void btnApply_Click(object sender, EventArgs e)
{
string fileName = @"C:\Users\Public\TestFolder\WriteText.txt";
string content = richTbWrite.Text;
System.IO.File.WriteAllText(fileName, content);
}