[問題] IsolatedStorageFileStream 的問題

看板WindowsPhone作者 (可倫)時間11年前 (2014/06/29 20:51), 11年前編輯推噓1(105)
留言6則, 3人參與, 最新討論串1/1
因為是開發的問題所以刪掉了預設內容... 是這樣的,小弟這兩天遇到一個完全不解的問題 首先,小弟將App的設定檔放在xml裡,用以下程式碼讀取XML string XML_PATH = Path.Combine(ApplicationData.Current.LocalFolder.Path, "config.xml"); using (IsolatedStorageFileStream isf = new IsolatedStorageFileStream(XML_PATH, FileMode.Open, isoStore)) { ifvm.loadConfig(isf); isf.Close(); isf.Dispose(); } public void loadConfig(Stream str) { im.load(str); } public void load(Stream str) { try { config = XDocument.Load(str); //會錯在這裡 } catch { throw new xmlException(); } } 這樣的操作在主程式中都沒有問題,但當同樣的程式碼放到taskAgent做背景程式的時候 loadConfig裡面的 config = XDocument.Load(str); 就會發生XML讀取錯誤,代碼是 Data at the root level is invalid ,而這個錯誤的Line和Position都指在檔案結尾 我現在最不懂的是,為什麼我也都把stream給close了, ScheduledActionService.LaunchForTest甚至安排在2分鐘後才啟動,但還是無法讀取XML 不知道有沒有前輩遇過類似的問題,可以給小弟一些建議... Orz --

12/24 10:39,
If 薪水<28K Then 離職
12/24 10:39

12/24 11:18,
else 跳槽
12/24 11:18

12/24 12:30,
goto 買樂透XD
12/24 12:30

12/24 12:41,
應該加入 #include"把上董事長女兒.h" 這個函式庫 :p
12/24 12:41

12/24 16:05,
樓上有.h沒有lib也是夢一場 include大家都會阿
12/24 16:05

12/24 19:11,
Error: invalid path
12/24 19:11
-- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 36.225.51.184 ※ 文章網址: http://www.ptt.cc/bbs/WindowsPhone/M.1404046290.A.2A9.html ※ 編輯: Kelunyang (36.225.51.184), 06/29/2014 21:15:11

06/29 23:12, , 1F
updateFPCC 的程式碼呢?
06/29 23:12, 1F
※ 編輯: Kelunyang (1.160.87.100), 06/30/2014 07:32:31

06/30 07:32, , 2F
已補上~
06/30 07:32, 2F

06/30 10:07, , 3F
在背景程式裡面log ApplicationData.Current.Loca....
06/30 10:07, 3F

06/30 10:07, , 4F
看看
06/30 10:07, 4F

06/30 10:28, , 5F
是有檔案的,不過我剛剛發現在xdocument.load前後加上lo
06/30 10:28, 5F

06/30 10:28, , 6F
ck就解開了@@
06/30 10:28, 6F
文章代碼(AID): #1Ji0lIAf (WindowsPhone)