序列化和反序列化

//建立以个text文档

//获取路径

//bin文件路径获取

mDownloadLasTextPath = Application.StartupPath + "\\DownLoadLasText.txt";
string mDownLoadLasText = File.ReadAllText(mDownloadLasTextPath);
//反序列化 获得文档中的内容
object pObj = ComponentBaseParameter.InputParameterStringToObject(mDownLoadLasText);
buttonEdit_ProjectFiles.Text = (pObj as ClassDownLoadLasPathText).LocalDownLoadText;
textEdit_FtpPath.Text = (pObj as ClassDownLoadLasPathText).FtpDownLoadText;
buttonEdit_Workspace.Text = (pObj as ClassDownLoadLasPathText).SavePathText;

//序列化 将内容存入text中

//序列化
ClassDownLoadLasPathText pDownLoadLasPathText = new ClassDownLoadLasPathText();
pDownLoadLasPathText.LocalDownLoadText = buttonEdit_ProjectFiles.Text;
pDownLoadLasPathText.SavePathText = buttonEdit_Workspace.Text;
pDownLoadLasPathText.FtpDownLoadText = textEdit_FtpPath.Text;
string pSerializationText = (pDownLoadLasPathText as ComponentBaseParameter).InputParameterString;
File.WriteAllText(mDownloadLasTextPath, pSerializationText);

posted @ 2017-10-19 14:45  基石  阅读(81)  评论(0编辑  收藏  举报