Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
160
PersistenceManager.Save Method, Save setting on diffrent location.
posted

Hi every one,

 I try to save XamWebGrid setting on a different location (for example “C:\ABC” Folder).

I use this code , but I cannot able to save memoryStream on a different location. How I can do this? Without open any Dialog Box.

public static void SaveSetting(DependencyObject obj, string fileName) {

      try {

        if (isSettingLoading == false) {

          PersistenceSettings persistaenceSetting = new PersistenceSettings();

          persistaenceSetting.SavePersistenceOptions = Infragistics.Silverlight.Primitives.PersistenceOption.AllButIgnored;

 

          MemoryStream memoryStream = PersistenceManager.Save(obj, persistaenceSetting);

 

          //string filePath = @"C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\XML\" + fileName;

 

          using (IsolatedStorageFile iso = IsolatedStorageFile.GetUserStoreForApplication()) {

            if (iso.FileExists(fileName))

              iso.DeleteFile(fileName);

            using (IsolatedStorageFileStream stream = new IsolatedStorageFileStream(fileName, FileMode.OpenOrCreate, iso)) {

              stream.Write(memoryStream.ToArray(), 0, (int)memoryStream.Length);

              stream.Close();

            }

          }

          memoryStream.Close();

          persistaenceSetting = null;

        }

      }

      catch (Exception ex) {

        MessageBox.Show(ex.Message, "CommonMethods.SaveSetting", MessageBoxButton.OK);

      }

    }

 

Parents Reply Children
No Data