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);
Silverlights security sandbox normally does not allow you to save files without using the SaveFileDialog.
If you can run your application as an out-of-browser application with elevated privileges, I beleive that removes the requirement to use the SaveFileDialog, but Silverlight will still restrict your file system access to the "My" folders (My Documents, My Music, etc).
If you want complete unfettered access to the file system you may need use COM interop.
Devin
Thanks Mr.Devin Rader
Thanks for replay.