code_junkie

Update a program setup

Nov 12th, 2011
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1. WebClient wc = new WebClient();
  2. wc.DownloadFile(UrlOfIniContainingLatestVersion, PlacetoSaveIniFile);
  3.  
  4. if (LatestVersion > CurrentVersion)
  5. {
  6. //Download update.
  7. }
  8.  
  9. wc.DownloadFile(UrlOfLatestSetupFile, PlaceToSaveSetupFile);
  10.  
  11. System.Diagnostics.Start(PathOfDownloadedSetupFile);
  12.  
  13. using System;
  14. using System.Runtime.InteropServices;
  15. using System.Text;
  16.  
  17. namespace Ini
  18. {
  19. /// <summary>
  20. /// Create a New INI file to store or load data
  21. /// </summary>
  22. public class IniFile
  23. {
  24. public string path;
  25.  
  26. [DllImport("kernel32")]
  27. private static extern long WritePrivateProfileString(string section,
  28. string key, string val, string filePath);
  29. [DllImport("kernel32")]
  30. private static extern int GetPrivateProfileString(string section,
  31. string key, string def, StringBuilder retVal,
  32. int size, string filePath);
  33.  
  34. /// <summary>
  35. /// INIFile Constructor.
  36. /// </summary>
  37. /// <PARAM name="INIPath"></PARAM>
  38. public IniFile(string INIPath)
  39. {
  40. path = INIPath;
  41. }
  42.  
  43. /// <summary>
  44. /// Write Data to the INI File
  45. /// </summary>
  46. /// <PARAM name="Section"></PARAM>
  47. /// Section name
  48. /// <PARAM name="Key"></PARAM>
  49. /// Key Name
  50. /// <PARAM name="Value"></PARAM>
  51. /// Value Name
  52. public void IniWriteValue(string Section, string Key, string Value)
  53. {
  54. WritePrivateProfileString(Section, Key, Value, this.path);
  55. }
  56.  
  57. /// <summary>
  58. /// Read Data Value From the Ini File
  59. /// </summary>
  60. /// <PARAM name="Section"></PARAM>
  61. /// <PARAM name="Key"></PARAM>
  62. /// <PARAM name="Path"></PARAM>
  63. /// <returns></returns>
  64. public string IniReadValue(string Section, string Key)
  65. {
  66. StringBuilder temp = new StringBuilder(255);
  67. int i = GetPrivateProfileString(Section, Key, "", temp,
  68. 255, this.path);
  69. return temp.ToString();
  70.  
  71. }
  72. }
  73. }
Add Comment
Please, Sign In to add comment