Veerendra Veerendra - 2 months ago 16
C# Question

how to create cookies in windows forms using c#?

how to create cookies in windows forms using c#?
or is there any way to save data "LIKE" cookies.

I want to save username and password in client machine so is there any other way to save

Thanks

Answer

Cookies are for websites, not Windows forms. But ultimately, cookies are just files that are dropped on the client machine that can be read and updated as you require. In which case, you could just drop and read files using System.IO.StreamWriter and System.IO.StreamReader. Something like this:

var writer = new System.IO.StreamWriter("MyFilename.txt");
writer.WriteLine("some text here");
writer.Close();

And to read the file:

var reader = new System.IO.StreamReader("MyFilename.txt");
var fileContents = reader.ReadToEnd();
reader.Close()