2012-04-29 20 views
1

我發現互聯網上此代碼來檢查文件是否存在問題與文件存在命令的Windows Phone

using (var store = IsolatedStorageFile.GetUserStoreForApplication()) 
      { 
       if (store.FileExists("Setting.xml")) 
       { 
        MessageBox.Show("have file"); 
       } 
       else 
       { 
        MessageBox.Show("haven't file");      
       } 
      } 

當我嘗試,它只能說明條件「還沒有文件」。是否有或沒有Setting.xml文件? (我可以通過XDocument data = XDocument.Load(「Setting.xml」)來加載這個文件;做或不做)?

回答

0

你能檢查這個「Setting.xml」文件是否在IsolatedStorage中?

因爲要從IsolatedStorage訪問文件,應該使用IsolatedStorageFileStream。