/// <summary> /// 儲存SN資訊至指定目錄 /// </summary> /// <param name="SN"></param> /// <param name="SaveDir">儲存檔案的目錄路徑</param> private void SaveSNToGivePath(string SN, string SaveDir, bool IsUpdateDate = false) { //先檢查目標資料夾存不存在;// try { if (Directory.Exists(SaveDir) == false) { //建立指定目錄;// Directory.CreateDirectory(SaveDir); } } catch (Exception) { //表示無法順利建立目錄;// return; } //儲存資訊至指定路徑;// IniManager KeyIni = new IniManager(string.Format(@"{0}\{1}", SaveDir, m_KeyFileName)); KeyIni.Write(m_RegistrySN, SN, m_KeyIniSettion); if (IsUpdateDate == true) { KeyIni.Write(m_RegistryInstallDate, DateTime.Now.ToString(m_DateFormat), m_KeyIniSettion); } }
/// <summary> /// 取得指定目錄下的Serial No /// </summary> /// <param name="KeyDir"></param> /// <returns></returns> private string GetKeyFromGivePath(string KeyDir) { //檢查資料夾是否存在;// if (Directory.Exists(KeyDir) == false) { return(null); } string FileFullPath = string.Format(@"{0}\{1}", KeyDir, m_KeyFileName); //檢查指定檔案是否存在;// if (File.Exists(FileFullPath) == false) { return(null); } IniManager KeyIni = new IniManager(FileFullPath); return(KeyIni.Read(m_RegistrySN, m_KeyIniSettion)); }