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)
精彩评论