<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>Snipplr</title>
<link>http://snipplr.com/tags/saving</link>
<description>Recent snippets posted on Snipplr.com</description>
<language>en-us</language>
<pubDate>Thu, 20 Jun 2013 03:18:54 GMT</pubDate>
<item>
<title>(Processing) Basic Processing Sketch for Image making/experimentation - Kobby</title>
<link>http://snipplr.com/view/63739/basic-processing-sketch-for-image-makingexperimentation/</link>
<description><![CDATA[ <p>This is an slightly more involved processing basic sketch I use when creating Imagery so I can save and output images at any point in time when the sketch is running.</p> ]]></description>
<pubDate>Wed, 07 Mar 2012 03:40:11 GMT</pubDate>
<guid>http://snipplr.com/view/63739/basic-processing-sketch-for-image-makingexperimentation/</guid>
</item>
<item>
<title>(iPhone) Easy function to get the path to the documents directory for data persistance - codeRefiner</title>
<link>http://snipplr.com/view/61316/easy-function-to-get-the-path-to-the-documents-directory-for-data-persistance/</link>
<description><![CDATA[ <p>Here is a simple function that will return the path to the documents directory so you can store data in it later</p> ]]></description>
<pubDate>Wed, 30 Nov 2011 06:24:50 GMT</pubDate>
<guid>http://snipplr.com/view/61316/easy-function-to-get-the-path-to-the-documents-directory-for-data-persistance/</guid>
</item>
<item>
<title>(ActionScript 3) Adobe AIR - Save text to local text file - GrfxGuru</title>
<link>http://snipplr.com/view/48136/adobe-air--save-text-to-local-text-file/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Mon, 31 Jan 2011 14:17:45 GMT</pubDate>
<guid>http://snipplr.com/view/48136/adobe-air--save-text-to-local-text-file/</guid>
</item>
<item>
<title>(Bash) Save entire web site with wget - minipark</title>
<link>http://snipplr.com/view/42571/save-entire-web-site-with-wget/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Wed, 20 Oct 2010 01:01:31 GMT</pubDate>
<guid>http://snipplr.com/view/42571/save-entire-web-site-with-wget/</guid>
</item>
<item>
<title>(SAS) Sending the LOG and OUTPUT from PC SAS to a seperate file - sarathannapareddy</title>
<link>http://snipplr.com/view/34726/sending-the-log-and-output-from-pc-sas-to-a-seperate-file/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Tue, 18 May 2010 13:17:18 GMT</pubDate>
<guid>http://snipplr.com/view/34726/sending-the-log-and-output-from-pc-sas-to-a-seperate-file/</guid>
</item>
<item>
<title>(C#) Presentation Framework Imaging Classes Gray-Scale Example (loading, drawing, encoding) - bryanlyman</title>
<link>http://snipplr.com/view/27700/presentation-framework-imaging-classes-grayscale-example-loading-drawing-encoding/</link>
<description><![CDATA[ <p>You must include these DLL references in your vsweb or vscode project:\r\nPresentationCore,\r\nPresentationFramework,\r\nWindowsBase. \r\nNotice how I am manipulating the RGB values of each pixel, this is the power of these classes. The Drawing classes have the pixel drawing capabilities to draw lines and such already written for you, but handling a grayscale byte for byte is faster than relying on their other classes. I also chose to load and encode as PNG, but they have loaders and encoders for other file types as well that work the same way.</p> ]]></description>
<pubDate>Thu, 04 Feb 2010 12:51:39 GMT</pubDate>
<guid>http://snipplr.com/view/27700/presentation-framework-imaging-classes-grayscale-example-loading-drawing-encoding/</guid>
</item>
<item>
<title>(C#) Persisting data using XML config files in WinForms (saving and restoring user and application data) - pckujawa</title>
<link>http://snipplr.com/view/24482/persisting-data-using-xml-config-files-in-winforms-saving-and-restoring-user-and-application-data/</link>
<description><![CDATA[ <p>References: [msdn blog](http://blogs.msdn.com/youssefm/archive/2010/01/21/how-to-change-net-configuration-files-at-runtime-including-for-wcf.aspx), [devX](http://www.devx.com/dotnet/Article/41639/0/page/1)

The .NET framework provides XML configuration files (in the Properties->Settings area of a C# project or in app.config) which make it easy to bind and save/restore data between application executions. I want to take it one step further and allow the user to save and restore multiple versions of these config files, rather than just relying on the last-entered data.

To get a file with any saved user settings, do this:  

    internal static void Export(string settingsFilePath)
    {
        Properties.Settings.Default.Save();
        var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
        config.SaveAs(settingsFilePath);
    }

The ConfigurationUserLevel setting is important; it determines whether you get the file you see in Settings.settings or the file which has the user's custom data.

(See example output file in source, as it won't show up correctly here.)

To import the settings in a file, you can use the Import method below. [EDIT: This is the old method which only works for settings persisted as strings. The Import code in the Source window is much better and more robust. I'm just leaving this in for reference.]

    internal static void Import(string settingsFilePath)
    {
        if (!File.Exists(settingsFilePath))
        {
            throw new FileNotFoundException();
        }

        var appSettings = Properties.Settings.Default;
        try
        {
            // Open settings file as XML
            var import = XDocument.Load(settingsFilePath);
            // Get the  elements
            var settings = import.XPathSelectElements("//setting");
            foreach (var setting in settings)
            {
                string name = setting.Attribute("name").Value;
                string value = setting.XPathSelectElement("value").FirstNode.ToString();

                try
                {
                    appSettings[name] = value; // throws SettingsPropertyNotFoundException
                }
                catch (SettingsPropertyNotFoundException spnfe)
                {
                    _logger.WarnException("An imported setting ({0}) did not match an existing setting.".FormatString(name), spnfe);
                }
            }
        }
        catch (Exception exc)
        {
            _logger.ErrorException("Could not import settings.", exc);
            appSettings.Reload(); // from last set saved, not defaults
        }
    }

References:  
[My question on StackOverflow](http://stackoverflow.com/questions/1869628/how-to-use-net-configuration-files-app-config-settings-settings-to-save-and-r)   

http://articles.techrepublic.com.com/5100-10878_11-1044975.html  

http://chiragrdarji.wordpress.com/2008/09/25/how-to-change-appconfig-file-run-time-using-c/  

http://msdn.microsoft.com/en-us/library/system.configuration.configuration.aspx  

http://stackoverflow.com/questions/132544/net-configuration-app-config-web-config-settings-settings  

[Saving Settings in .NET 2.0 Apps](http://www.ddj.com/windows/187002743)</p> ]]></description>
<pubDate>Tue, 08 Dec 2009 18:24:37 GMT</pubDate>
<guid>http://snipplr.com/view/24482/persisting-data-using-xml-config-files-in-winforms-saving-and-restoring-user-and-application-data/</guid>
</item>
</channel>
</rss>