/// <summary> /// 从"独立存贮空间"取程序第一次运行的时间并解密 /// </summary> /// <returns></returns> public static string GetDataTime() { string fromDataTime; //按用户、域、程序集获取独立存储区 IsolatedStorageFile isoStore = IsolatedStorageFile.GetStore(IsolatedStorageScope.User | IsolatedStorageScope.Domain | IsolatedStorageScope.Assembly, null, null); string[] myusername = isoStore.GetDirectoryNames(UIConstants.IsolatedStorageDirectoryName); if (myusername.Length == 0) //没有文件夹 { return(string.Empty); //域中没有他的目录 } myusername = isoStore.GetFileNames(UIConstants.IsolatedStorage); if (myusername.Length == 0) //没有文件 { return(string.Empty); //域中没有他的用户名 } else { using (IsolatedStorageFileStream isoStream1 = new IsolatedStorageFileStream(UIConstants.IsolatedStorage, FileMode.OpenOrCreate, isoStore)) { using (StreamReader reader = new StreamReader(isoStream1)) { fromDataTime = reader.ReadLine(); } } if (!string.IsNullOrEmpty(fromDataTime)) //解密 { try { fromDataTime = EncodeHelper.DesDecrypt(fromDataTime, UIConstants.IsolatedStorageEncryptKey); } catch { } } return(fromDataTime); } }