简体   繁体   中英

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

i want to save username and password in client machine

If you set the password form type to "password" the client browser should do all the work for you here. When they log in it asks if they want to save these credentials for the web site.

*EDIT: If all you are looking to do is write a cookie using c#, the answer was only a quick google search away... http://msdn.microsoft.com/en-us/library/aa287547(v=vs.71).aspx

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()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM