You can not protect a text file with a password out of the box. You would need to encapsulate it, with an other application to do so.
The simplest way, would be to use a Zip File.
As taken form this post by Cheeso using DotNetZip:
using (var zip = new ZipFile())
{
zip.Password= "VerySecret!!";
zip.AddFile("test.txt");
zip.Save("Archive.zip");
}
This results in 2 steps.
- Create your files
- Zip them and choose a password.