Advertisement
nateshoffner

Untitled

Nov 2nd, 2011
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.90 KB | None | 0 0
  1. /*
  2. INI Parser
  3. */
  4.  
  5. [DllImport("kernel32")]
  6. private static extern long WritePrivateProfileString(string section, string key, string val, string filePath);
  7.  
  8. [DllImport("kernel32")]
  9. private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath);
  10.  
  11. public static void IniWriteValue(string filePath, string section, string key, string value, string comment)
  12. {
  13.     var str = string.Format(" {0}", value);
  14.     if (comment != null) str += string.Format(" {0} {1} ", CommentDelimiter, comment);
  15.     WritePrivateProfileString(section, key, str, filePath);
  16. }
  17.  
  18.  
  19. /*
  20. Config Getter/Setter
  21. */
  22.  
  23. public static string Name
  24. {
  25.     get { return INI.IniReadValue(Files.INI.Config, "client", "name"); }
  26.     set {INI.IniWriteValue(Files.INI.Config, "client", "name", value,"Choose a name for your player, must be less than 16 characters"); }
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement