序列化和反序列化

//建立以个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);

原文地址:https://www.cnblogs.com/lzh5d/p/7692434.html