Q
更新程序設置
1
A
回答
1
以下是我如何實現我之前編寫的更新程序。
首先,您從服務器上獲取ini文件。該文件將包含有關最新版本的信息以及安裝文件的位置。獲取該文件並不難。
WebClient wc = new WebClient();
wc.DownloadFile(UrlOfIniContainingLatestVersion, PlacetoSaveIniFile);
我還設置了從本地ini文件讀取信息以確定最新版本。這樣做的更好方法是直接讀取文件版本,但我沒有代碼來執行該操作。
接下來我們做一個非常簡單的檢查,看看這兩個版本如何比較和下載更新。
if (LatestVersion > CurrentVersion)
{
//Download update.
}
下載更新與下載原始ini一樣簡單。您只需更改更改這兩個參數。
wc.DownloadFile(UrlOfLatestSetupFile, PlaceToSaveSetupFile);
現在您已經下載了該文件,這是運行安裝程序的一個簡單問題。
System.Diagnostics.Start(PathOfDownloadedSetupFile);
如果你不知道如何讀的ini文件,我發現下面的類在某個地方在CodeProject
using System;
using System.Runtime.InteropServices;
using System.Text;
namespace Ini
{
/// <summary>
/// Create a New INI file to store or load data
/// </summary>
public class IniFile
{
public string path;
[DllImport("kernel32")]
private static extern long WritePrivateProfileString(string section,
string key, string val, string filePath);
[DllImport("kernel32")]
private static extern int GetPrivateProfileString(string section,
string key, string def, StringBuilder retVal,
int size, string filePath);
/// <summary>
/// INIFile Constructor.
/// </summary>
/// <PARAM name="INIPath"></PARAM>
public IniFile(string INIPath)
{
path = INIPath;
}
/// <summary>
/// Write Data to the INI File
/// </summary>
/// <PARAM name="Section"></PARAM>
/// Section name
/// <PARAM name="Key"></PARAM>
/// Key Name
/// <PARAM name="Value"></PARAM>
/// Value Name
public void IniWriteValue(string Section, string Key, string Value)
{
WritePrivateProfileString(Section, Key, Value, this.path);
}
/// <summary>
/// Read Data Value From the Ini File
/// </summary>
/// <PARAM name="Section"></PARAM>
/// <PARAM name="Key"></PARAM>
/// <PARAM name="Path"></PARAM>
/// <returns></returns>
public string IniReadValue(string Section, string Key)
{
StringBuilder temp = new StringBuilder(255);
int i = GetPrivateProfileString(Section, Key, "", temp,
255, this.path);
return temp.ToString();
}
}
}
0
聽起來像是你可能能夠使用ClickOnce
相關問題
- 1. 更新應用程序設置
- 2. 應用程序更新刪除設置
- 3. iOS。應用程序更新後保護設置不會重置?
- 4. 在Java應用程序中保存和更新配置設置
- 5. 更改應用程序中設置更改的系統設置
- 6. 排序圖標不更新上設置
- 7. 更新項設置
- 8. 更新設置request.POST
- 9. SQL更新設置
- 10. 將c#WPF複選框綁定到應用程序設置和更新設置
- 11. 更新和更改設置plist文件與新版本的應用程序
- 12. 更改.NET應用程序設置而不重新編譯
- 13. iPhone更新的應用程序版本(在設置)
- 14. Android - 更改設置後刷新應用程序
- 15. 如何從應用程序執行設置以更新它?
- 16. facebook應用程序設置opengraph儀表板不更新
- 17. 如何爲Vb.net應用程序創建更新設置
- 18. WiX補丁程序是否更新註冊表設置?
- 19. Laravel應用程序不會更新數據庫連接設置
- 20. MongoDB C#驅動程序 - 無需設置/替換的更新
- 21. Android:爲應用程序設置自動更新
- 22. Instagram更新至5.0。如何設置「InstagramCaption」程序與iPhone掛鉤
- 23. 角CLI更新應用程序設置,如「」前綴」
- 24. 如何設置新的導軌程序
- 25. Apigee - 設置新應用程序
- 26. 設置新的Facebook應用程序
- 27. 以Java重新設置密碼程序
- 28. 如何在eclipse中設置新程序
- 29. 反映設置更新視圖更新
- 30. 更新設置後更新uiimageview
您是否將您的安裝設置爲MSI? – EBGreen 2008-10-29 14:01:24