Exemplo n.º 1
0
        private void DirtyFileAutoSave(RepositoryItemBase itemToSave)
        {
            try
            {
                RepositoryItemBase itemCopy = itemToSave.CreateCopy(false);

                //create smiliar folders structure
                string ItemOriginalpath     = itemToSave.ContainingFolderFullPath;
                string ItemContainingfolder = itemToSave.ContainingFolder;
                string itemAutoSavePath     = ItemOriginalpath.Replace(ItemOriginalpath, mAutoSaveFolderPath);
                itemAutoSavePath = Path.Combine(itemAutoSavePath, ItemContainingfolder);
                if (!Directory.Exists(itemAutoSavePath))
                {
                    Directory.CreateDirectory(itemAutoSavePath);
                }

                //save item
                itemCopy.SaveToFile(Path.Combine(itemAutoSavePath, itemCopy.FileName.ToString()));
            }
            catch (Exception ex)
            {
                Reporter.ToLog(eLogLevel.ERROR, string.Format("AutoSave: Failed to AutoSave the item:'{0}'", itemToSave.ItemName), ex);
            }
        }