WinForm read-write. ini file

Source: Internet
Author: User
Tags ini int size key string

1, in the head reference

 
  
  
  1. [DllImport ("kernel32")]
  2. private static extern long WritePrivateProfileString (string section,
  3. String key,string val,string FilePath);
  4. [DllImport ("kernel32")]
  5. private static extern int getprivateprofilestring (string section,
  6. String Key,string def, StringBuilder RetVal,
  7. int size,string filePath);


2, write. ini

 
  
  
  1. WritePrivateProfileString ("Setup", "UserName", Userno.) text,application.startuppath+ "\\mcs.ini");


3, read. ini

 
  
  
  1. StringBuilder temp = new StringBuilder (255);
  2. int i = getprivateprofilestring ("Setup", "UserName", "" ", temp,255, application.startuppath+" \\mcs.ini ");
  3. Userno. Text = temp. ToString ();



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.