private void SaveAndUploadHeadPic() { if (this.pb_photo_cut.BackgroundImage != null) { Bitmap savpic = new Bitmap(this.pb_photo_cut.BackgroundImage); string addressonlyid = CommonStaticParameter.ICONS + @"\" + this.user.Id.ToString() + ".png"; string address = CommonStaticParameter.ICONS + @"\" + this.user.Id.ToString() + "__" + DateTime.Now.Ticks.ToString() + ".png"; if (!Directory.Exists(CommonStaticParameter.ICONS)) Directory.CreateDirectory(CommonStaticParameter.ICONS); if (File.Exists(addressonlyid)) { FileInfo oldfi = new FileInfo(addressonlyid); oldfi.Delete(); } savpic.Save(addressonlyid); //保存临时文件 //ToRoundPic(address).Save(address); if (fileop == null) { string _ip = Securit.DeDES(FileReadAndWrite.IniReadValue("ftpfile", "ip")); string _id = Securit.DeDES(FileReadAndWrite.IniReadValue("ftpfile", "id")); string _pwd = Securit.DeDES(FileReadAndWrite.IniReadValue("ftpfile", "pwd")); fileop = new FileUpDown(_ip, _id, _pwd); } try { fileop.IsConnectSucceed( this.user.Id.ToString() + ".png", "Iconpics"); bool isxe = fileop.DirectoryExist(this.user.Id.ToString() + ".png", "Iconpics"); if (isxe) { fileop.DeleteFileName(this.user.Id.ToString() + ".png", "Iconpics"); } fileop.Upload(addressonlyid, "Iconpics"); fileop.Rename(addressonlyid, this.user.Id.ToString() + ".png", "Iconpics"); themain.RefreshHeaderPic(); MessageBox.Show("上传成功!"); } catch (Exception exp) { MessageBox.Show("上传失败"+exp.ToString()); return; } } }
void CreativeFileUpDownClass_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { string _ip = Securit.DeDES(FileReadAndWrite.IniReadValue("ftpfile", "ip")); string _id = Securit.DeDES(FileReadAndWrite.IniReadValue("ftpfile", "id")); string _pwd = Securit.DeDES(FileReadAndWrite.IniReadValue("ftpfile", "pwd")); fileUpDown = new FileUpDown(_ip, _id, _pwd); }
private void onlineUpDate() { #region 在线更新 string thePreUpdateDate = ""; try { string _ip = Securit.DeDES(FileReadAndWrite.IniReadValue("ftpfile", "ip")); string _id = Securit.DeDES(FileReadAndWrite.IniReadValue("ftpfile", "id")); string _pwd = Securit.DeDES(FileReadAndWrite.IniReadValue("ftpfile", "pwd")); FileUpDown fileUpDown = new FileUpDown(_ip, _id, _pwd); string theLastsUpdateVersionNumber = GetTheUpdateVersionNum(System.Windows.Forms.Application.StartupPath);//上次的版本号 fileUpDown.Download(CommonStaticParameter.TEMP, "UpdateConfig.xml", "WorkLog"); thePreUpdateDate = GetTheUpdateVersionNum(CommonStaticParameter.TEMP);//这次的版本号 if (thePreUpdateDate != "") { //如果客户端将升级的应用程序的更新版本号与服务器上的不一致则进行更新 if (thePreUpdateDate != theLastsUpdateVersionNumber) { MessageBox.Show("有可更新的版本,程序将关闭…", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information); { this.Close(); themain.DialogResult = DialogResult.OK; return; } } else { MessageBox.Show("当前版本为最新版" + thePreUpdateDate + ",无需更新"); return; } } else { onlineUpDate(); } } catch (Exception ex) { MessageBox.Show("程序出错 原因:" + ex.Message.ToString()); } #endregion }