开发者

C++/CLi - Using streamwriter to write to text file is overwriting what's already there

The code I'm using to write a string to a file is as follows:

void addToWhitelist(System::String ^emailAddress)
{
StreamWriter ^pwriter = gcnew StreamWriter("whitelist.txt");
pwriter->WriteLine(emailAddress);
pwriter->Close();
}

This works well, but as soon as I run the function again, the string that was written开发者_高级运维 to the text file is overwritten with the new value. How would I go about appending the string to the file on a new line?


Try adding "true" as second parameter to StreamWriter constructor. (Boolean value says whether to append)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜