第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會有你想問的

序列化包含字典成員的類

序列化包含字典成員的類

當(dāng)年話下 2019-07-17 14:30:07
序列化包含字典成員的類擴(kuò)展到我的早期問題,我決定序列化我的config文件類,它運(yùn)行得很好。我現(xiàn)在想要存儲要映射的驅(qū)動(dòng)器字符的關(guān)聯(lián)數(shù)組(鍵是驅(qū)動(dòng)器字母,值是網(wǎng)絡(luò)路徑),并嘗試使用Dictionary, HybridDictionary,和Hashtable但是,在調(diào)用時(shí)總是會收到以下錯(cuò)誤ConfigFile.Load()或ConfigFile.Save():反映類型‘App.ConfigFile’時(shí)出錯(cuò)。[Snip]System.NotSupportdException:無法序列化成員App.Configfile.mempdDrives[Snip]根據(jù)我所讀過的字典和HashTables可以被序列化,那么我做錯(cuò)了什么呢?[XmlRoot(ElementName="Config")]public class ConfigFile{     public String guiPath { get; set; }     public string configPath { get; set; }     public Dictionary<string, string> mappedDrives = new Dictionary<string, string>();     public Boolean Save(String filename)     {         using(var filestream = File.Open(filename, FileMode.OpenOrCreate,FileAccess.ReadWrite))         {             try             {                 var serializer = new XmlSerializer(typeof(ConfigFile));                 serializer.Serialize(filestream, this);                 return true;             } catch(Exception e) {                 MessageBox.Show(e.Message);                 return false;             }         }     }     public void addDrive(string drvLetter, string path)     {         this.mappedDrives.Add(drvLetter, path);     }     public static ConfigFile Load(string filename)     {         using (var filestream = File.Open(filename, FileMode.Open, FileAccess.Read))         {             try             {                 var serializer = new XmlSerializer(typeof(ConfigFile));                 return (ConfigFile)serializer.Deserialize(filestream);             }             catch (Exception ex)             {                 MessageBox.Show(ex.Message + ex.ToString());                 return new ConfigFile();             }         }     }}
查看完整描述

3 回答

  • 3 回答
  • 0 關(guān)注
  • 428 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號