<?xml version="1.0" encoding="utf-8"?>
<!-- If you are running a bot please visit this policy page outlining rules you must respect. http://www.livejournal.com/bots/ -->
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:lj="http://www.livejournal.com">
  <id>urn:lj:livejournal.com:atom1:csharp4u</id>
  <title>C# For You</title>
  <subtitle>Sharpen your skills</subtitle>
  <author>
    <name>Larry's C# Musings</name>
  </author>
  <link rel="alternate" type="text/html" href="http://csharp4u.livejournal.com/"/>
  <link rel="self" type="text/xml" href="http://csharp4u.livejournal.com/data/atom"/>
  <updated>2006-02-06T03:38:53Z</updated>
  <lj:journal userid="8474773" username="csharp4u" type="personal"/>
  <link rel="service.feed" type="application/x.atom+xml" href="http://csharp4u.livejournal.com/data/atom" title="C# For You"/>
  <link rel="hub" href="http://pubsubhubbub.appspot.com/"/>
  <entry>
    <id>urn:lj:livejournal.com:atom1:csharp4u:2261</id>
    <link rel="alternate" type="text/html" href="http://csharp4u.livejournal.com/2261.html"/>
    <link rel="self" type="text/xml" href="http://csharp4u.livejournal.com/data/atom/?itemid=2261"/>
    <title>Aside</title>
    <published>2006-02-06T03:36:27Z</published>
    <updated>2006-02-06T03:38:53Z</updated>
    <content type="html">Here are some musings about a couple of things I ended up doing this weekend.  &lt;br /&gt;&lt;br /&gt;First, the &lt;code&gt;Splitter&lt;/code&gt; Control that you get in Visual Studio isn't the most obvious thing in the world to start working with.  But, it is insanely easy to use once you know how.  Put part A, Dock A to the left.  Put your Splitter and also dock it to the left.  Put part B and dock it to the middle.  Done.  The splitter will now let you divide the space in the window between A and B.&lt;br /&gt;&lt;br /&gt;Second, the &lt;code&gt;Reflection.Emit&lt;/code&gt; works pretty much like they say on the MSDN site &lt;a href="http://msdn2.microsoft.com/en-us/library/system.reflection.emit.propertybuilder.aspx"&gt;http://msdn2.microsoft.com/en-us/library/system.reflection.emit.propertybuilder.aspx&lt;/a&gt;.  I borrowed liberally from the code there and just tweaked it enough to allow you to input the object description in an XML like syntax.  Some things I have yet to do include: setting the default values for the properties and attributing the properties to make them work with the &lt;code&gt;PropertyGrid&lt;/code&gt; better &lt;a href="http://www.c-sharpcorner.com/Code/2004/June/PropertyGridInCSharp.asp"&gt;http://www.c-sharpcorner.com/Code/2004/June/PropertyGridInCSharp.asp&lt;/a&gt;.  &lt;br /&gt;&lt;br /&gt;I currently have the example reading in XMLish descriptions like:&lt;br /&gt;&lt;pre&gt;
&lt;code&gt;
&amp;lt class name="bob" &amp;gt
  &amp;lt property name="oneString" type="System.String" default="hi"/ &amp;gt
  &amp;lt property name="oneInt32" type="System.Int32" default="hi"/ &amp;gt
  &amp;lt property name="twoString" type="System.String" default="hi"/ &amp;gt
&amp;lt /class &amp;gt
&lt;/code&gt;
&lt;/pre&gt;&lt;br /&gt;and producing an internal assembly as well as saving it out to the disk.  It also uses ILDASM to disassemble the .dll and displays the results.  Lastly, it instantiates one of the new objects and hooks it to a &lt;code&gt;PropertyGrid&lt;/code&gt;.&lt;br /&gt;&lt;br /&gt;I should get this finished and integrated into the SQLTester sometime this week.&lt;br /&gt;&lt;a href="http://smithmier.com/ReflectionEmitTester.zip"&gt;Project&lt;/a&gt;&lt;br /&gt;&lt;a name="cutid1"&gt;&lt;/a&gt;&lt;br /&gt;&lt;img src="http://smithmier.com/ReflectionEmitTester.png"&gt;</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:csharp4u:2022</id>
    <link rel="alternate" type="text/html" href="http://csharp4u.livejournal.com/2022.html"/>
    <link rel="self" type="text/xml" href="http://csharp4u.livejournal.com/data/atom/?itemid=2022"/>
    <title>Using SQL server from a WinForm (Part 4)</title>
    <published>2006-01-30T03:35:26Z</published>
    <updated>2006-01-30T03:35:26Z</updated>
    <content type="html">Ok, lets dig into the results we are getting and get some type information.  The system table &lt;code&gt;systypes&lt;/code&gt; has the information about the types we are retrieving.  If we alter our SQL we can get this information back in the same query:&lt;br /&gt;&lt;pre&gt;
&lt;code&gt;
SELECT * FROM
(
	SELECT
		sc.colid, sc.name, sc.length, sc.xprec, sc.xscale, st.name AS typeName, st.name AS extTypeName
	FROM 
		syscolumns sc 
	JOIN 
		sysobjects so ON so.id = sc.id 
	JOIN
		systypes st ON st.xtype = sc.xtype and st.xusertype = sc.xusertype
	WHERE 
		so.name = 'sp_help' 
	AND
		sc.xtype = sc.xusertype

	UNION

	SELECT 
		sc.colid, sc.name, sc.length, sc.xprec, sc.xscale, st.name AS typeName, stExt.name AS extTypeName
	FROM 
		syscolumns sc 
	JOIN 
		sysobjects so ON so.id = sc.id 
	JOIN
		systypes st ON st.xtype = sc.xtype AND st.xtype = sc.xusertype
	JOIN
		systypes stExt ON st.xtype = sc.xtype AND st.xusertype = sc.xusertype
	WHERE 
		so.name = 'sp_help' 
	AND
		sc.xtype != sc.xusertype
) x
ORDER BY x.colid
&lt;/code&gt;
&lt;/pre&gt;&lt;br /&gt;There are two sub queries &lt;code&gt;union&lt;/code&gt;ed together because you can do a derived type that is built up of native types.  This way, both names are available.  Now we can build up our object using &lt;code&gt;Reflection.Emit&lt;/code&gt; and hook a &lt;code&gt;PropertyGrid&lt;/code&gt; up to it for our UI.  I found an article at Code Project that has a library for doing just this, but I didn't care for the implementation:  &lt;a href="http://www.codeproject.com/cs/miscctrl/CustomPropGrid.asp"&gt;http://www.codeproject.com/cs/miscctrl/CustomPropGrid.asp&lt;/a&gt;.  This post is late and light on code. (*sigh*)&lt;br /&gt;&lt;br /&gt;I am going to have to come back next time and build the object with properties.  I am probably going to base it on code from &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemreflectionemitpropertybuilderclasstopic.asp"&gt;http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemreflectionemitpropertybuilderclasstopic.asp&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://smithmier.com/SqlServerTester4.zip"&gt;project files and source code&lt;/a&gt;</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:csharp4u:1551</id>
    <link rel="alternate" type="text/html" href="http://csharp4u.livejournal.com/1551.html"/>
    <link rel="self" type="text/xml" href="http://csharp4u.livejournal.com/data/atom/?itemid=1551"/>
    <title>Using SQL server from a WinForm (Part 3)</title>
    <published>2006-01-16T03:50:38Z</published>
    <updated>2006-01-16T12:08:58Z</updated>
    <content type="html">Continuing with the SqlServerTester, let's begin to add the ability to automatically generate a call to a selected stored procedure.&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Add a new &lt;code&gt;GroupBox&lt;/code&gt; containing &lt;code&gt;RadioButton&lt;/code&gt;s for the Stored Procedure Type (System or User) with appropriate background code, a &lt;code&gt;ComboBox&lt;/code&gt; to contain the stored procedure names, and a generate &lt;code&gt;Button&lt;/code&gt;.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;We are going to extend the &lt;code&gt;RadioButton&lt;/code&gt; &lt;code&gt;EventHandler&lt;/code&gt; model to include an action other than just keeping the buttons selected correctly by adding a call to another procedure just after the setting of the currently selected &lt;code&gt;RadioButton&lt;/code&gt; &lt;code&gt;Checked&lt;/code&gt; to &lt;code&gt;true&lt;/code&gt;:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;
	private void StoredProcedureType_CheckedChanged(object sender, System.EventArgs e)
	{
		this.radSystem.CheckedChanged -= new System.EventHandler(this.StoredProcedureType_CheckedChanged);
		this.radUser.CheckedChanged -= new System.EventHandler(this.StoredProcedureType_CheckedChanged);
		radSystem.Checked = false;
		radUser.Checked = false;
		((RadioButton) sender).Checked = true;
		UpdateStoredProcedureComboBox();
		this.radSystem.CheckedChanged += new System.EventHandler(this.StoredProcedureType_CheckedChanged);
		this.radUser.CheckedChanged += new System.EventHandler(this.StoredProcedureType_CheckedChanged);	
	}
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;To fill our &lt;code&gt;ComboBox&lt;/code&gt; with stored procedure names, we will query the &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_sys_00_690z.asp"&gt;System Tables&lt;/a&gt; with the sql:&lt;br /&gt;&lt;code&gt;string sql_GetStoredProcedures = "select name from sysobjects where xtype = 'p'";&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;To create our stored procedure template, we need to query another System Table, this time, the &lt;code&gt;syscolumns&lt;/code&gt; one.  For now, let's just get the results and put them in the &lt;code&gt;DataGrid&lt;/code&gt; with the following sql:&lt;br /&gt;&lt;code&gt;string sql_GetStoredProcedures = "select sc.* from syscolumns sc join sysobjects so on so.id = sc.id where so.name = '"+cmbStoredProcedures.SelectedItem+"'";&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;That's it for today.  Next, we will look at an interesting way of using &lt;strike&gt;&lt;code&gt;Remoting.Emit&lt;/code&gt;&lt;/strike&gt; &lt;code&gt;Reflection.Emit&lt;/code&gt; and a &lt;code&gt;PropertyGrid&lt;/code&gt; to get values for the stored procedure parameters.&lt;br /&gt;&lt;a href="http://smithmier.com/SqlServerTester3.zip"&gt;project files and source code&lt;/a&gt;</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:csharp4u:1408</id>
    <link rel="alternate" type="text/html" href="http://csharp4u.livejournal.com/1408.html"/>
    <link rel="self" type="text/xml" href="http://csharp4u.livejournal.com/data/atom/?itemid=1408"/>
    <title>Using SQL server from a WinForm (Part 2)</title>
    <published>2006-01-09T05:24:14Z</published>
    <updated>2006-01-09T05:26:51Z</updated>
    <content type="html">Continuing with the same solution, let's explore three different ways to connect to the same database.  We used the native System.Data.SqlClient to connect last time, lets also try an ODBC and an OLE connection.&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;Add &lt;code&gt;using System.Data.Odbc;&lt;/code&gt; and &lt;code&gt;using System.Data.OleDb;&lt;/code&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;We'll also add some RadioButtons for the connection type (&lt;code&gt;radNativeSQL&lt;/code&gt;, &lt;code&gt;radODBC&lt;/code&gt;, and &lt;code&gt;radOle&lt;/code&gt;).  To keep them visually separate, add a couple of GroupBox(es) to put them in.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Instead of using a &lt;code&gt;SqlConnection&lt;/code&gt;, &lt;code&gt;SqlCommand&lt;/code&gt;, and &lt;code&gt;SqlDataAdapter&lt;/code&gt;; we will use the interfaces &lt;code&gt;IDbConnection&lt;/code&gt;, &lt;code&gt;IDbCommand&lt;/code&gt;, and &lt;code&gt;IDbDataAdapter&lt;/code&gt;.  These are interfaces that it is required for data providers to implement.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;pre&gt;
			IDbCommand command = null;
			IDbConnection conn = null;
			IDbDataAdapter dataAdapter = null;
&lt;/pre&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Within the run button click event handler (btnRun_Click) add code to open the different type connections as shown below:&lt;br /&gt;&lt;code&gt;&lt;pre&gt;
			conn = new SqlConnection(txtConnectionString.Text);
			conn.Open();
			command = new SqlCommand(txtSQL.Text, (SqlConnection) conn);
			dataAdapter = new SqlDataAdapter();
&lt;/pre&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;pre&gt;
        		conn = new OdbcConnection(txtConnectionString.Text);
			conn.Open();
			command = new OdbcCommand(txtSQL.Text, (OdbcConnection) conn);
			dataAdapter = new OdbcDataAdapter();
&lt;/pre&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;pre&gt;
			conn = new OleDbConnection(txtConnectionString.Text);
			conn.Open();
			command = new OleDbCommand(txtSQL.Text, (OleDbConnection) conn);
			dataAdapter = new OleDbDataAdapter();
&lt;/pre&gt;&lt;/code&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;In a similar way, add the controls and code to handle the three different ComandType(s): &lt;code&gt;CommandType.StoredProcedure&lt;/code&gt;, &lt;code&gt;CommandType.TableDirect&lt;/code&gt;, and &lt;code&gt;CommandType.Text&lt;/code&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;We will also add the ExecuteNonQuery Query type.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;You will need to provide different connection strings depending on the connection type you want to use.  Here are the ones I use at home for testing:&lt;br /&gt;&lt;code&gt;&lt;pre&gt;
[native sql server]
Password=xxxx;Persist Security Info=True;User ID=Golf;Initial Catalog=Commerce;Data Source=CORNBREAD

[odbc]
Driver={SQL Server};Server=CORNBREAD;UID=Golf;PWD=xxxx;Database=Commerce;

[oledb]
Provider=SQLOLEDB.1;Password=xxxx;Persist Security Info=True;User ID=Golf;Initial Catalog=Commerce;Data Source=CORNBREAD
&lt;/pre&gt;&lt;/code&gt;&lt;br /&gt;Play around with the different connection types and command types and notice how different combinations behave differently (for example, only Ole implements TableDirect).  Also try executing &lt;code&gt;sp_help 'sysobjects'&lt;/code&gt; with each of the connection types/command types.&lt;br /&gt;&lt;a href="http://smithmier.com/SqlServerTester2.zip"&gt;project files and source code&lt;/a&gt;</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:csharp4u:1076</id>
    <link rel="alternate" type="text/html" href="http://csharp4u.livejournal.com/1076.html"/>
    <link rel="self" type="text/xml" href="http://csharp4u.livejournal.com/data/atom/?itemid=1076"/>
    <title>(enumType)Enum.Parse(typeof(enumType),stringOfEnum)</title>
    <published>2006-01-06T15:41:50Z</published>
    <updated>2006-01-06T15:41:50Z</updated>
    <content type="html">Quick tip on converting from a string into an enumeration. Given:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;pre&gt;
		enum MyShape
		{
			Circle,
			Triangle,
			Square,
			Rhombus
		}
&lt;/pre&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;you can do:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;pre&gt;
		MyShape bob;
		bob = (MyShape) Enum.Parse(typeof (MyShape), "Square", true);
		MyShape jim;
		jim = (MyShape) Enum.Parse(typeof (MyShape), "cIRcLE", true);
&lt;/pre&gt;&lt;br /&gt;&lt;/code&gt;</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:csharp4u:857</id>
    <link rel="alternate" type="text/html" href="http://csharp4u.livejournal.com/857.html"/>
    <link rel="self" type="text/xml" href="http://csharp4u.livejournal.com/data/atom/?itemid=857"/>
    <title>Using SQL server from a WinForm (Part 1)</title>
    <published>2006-01-06T04:24:34Z</published>
    <updated>2006-01-06T04:24:34Z</updated>
    <content type="html">&lt;ol&gt;&lt;br /&gt;&lt;li&gt;Start with a simple windows form.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Add a &lt;code&gt;TextBox&lt;/code&gt; and a &lt;code&gt;Lable&lt;/code&gt; for the connection string.  &lt;br /&gt;&lt;/li&gt;&lt;li&gt;Get your connection string by creating a text document on your desk top and changing the name to bob.udl.  Double click on it and you get the Data Link Properties application that walks you through connecting.  Then open up bob.udl (Universal Data Link?) in a text editor and bob's your uncle.  Ok, you must remove the &lt;code&gt;Provider=SQLOLEDB.1;&lt;/code&gt; from it to make it work correctly, but it is still a cool way to get a connection string.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Add a SQL &lt;code&gt;Lable&lt;/code&gt; and &lt;code&gt;TextBox&lt;/code&gt;.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Next, add a multiline output &lt;code&gt;TextBox&lt;/code&gt; and a run &lt;code&gt;Button&lt;/code&gt;.  Add an &lt;code&gt;EventHandler&lt;/code&gt; for the &lt;code&gt;Click&lt;/code&gt; event on the Run button by double clicking on it.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Add a &lt;code&gt;using System.Data.SqlClient;&lt;/code&gt; to the top and then open your connection to the SQL database using the supplied connection string, and run the supplied command against it, putting the output into the output &lt;code&gt;TextBox&lt;/code&gt;.  At this point, we are going to &lt;code&gt;ExecuteScalar&lt;/code&gt; and expect only a single value back.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;			SqlConnection conn = new SqlConnection(txtConnectionString.Text);&lt;br /&gt;			conn.Open();&lt;br /&gt;			SqlCommand command = new SqlCommand(txtSQL.Text,conn);&lt;br /&gt;			txtOutput.Text = command.ExecuteScalar().ToString();&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Let's run it and see what we get.  Use the following SQL &lt;code&gt;select count(distinct name) from sysobjects where name not like '%sys%';&lt;/code&gt;.  I get 46 as my output, because I have created 46 user defined objects in the database I am connecting to.  &lt;br /&gt;&lt;/li&gt;&lt;li&gt;Well, what if we want to get back more than a single value?  Let's start by extracting a method that contains lines 3 and 4 from above.  We then add a second output control, a &lt;code&gt;DataGrid&lt;/code&gt;.  We want to get a &lt;code&gt;DataSet&lt;/code&gt; back from SQL so that we can bind it to the control.  We use a &lt;code&gt;DataAdapter&lt;/code&gt; to fill our &lt;code&gt;DataSet&lt;/code&gt; and then assign it as a &lt;code&gt;DataSource&lt;/code&gt; on the &lt;code&gt;DataGrid&lt;/code&gt;.  Add the folowing code in a new method:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;			SqlCommand command = new SqlCommand(txtSQL.Text,conn);&lt;br /&gt;			SqlDataAdapter sda = new SqlDataAdapter(command);&lt;br /&gt;			DataSet dataSet = new DataSet("GetDataSet Results");&lt;br /&gt;			sda.Fill(dataSet);&lt;br /&gt;			dgrOutput.DataSource = dataSet;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;We will need to add some type of control to decide which one of these methods we want to run when you press the run button.  Let's use a couple of &lt;code&gt;RadioButton&lt;/code&gt;(s) and code to hide the &lt;code&gt;TextBox&lt;/code&gt; or &lt;code&gt;DataGrid&lt;/code&gt; depending on what results are returned.  I always set one (and only one) &lt;code&gt;RadioButton&lt;/code&gt; to &lt;code&gt;Checked&lt;/code&gt; and then build a method to be fired by all of them that hides/unhides and checks/unchecks as required.  You should add something like this:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;			this.radExecuteScalar.CheckedChanged -= new System.EventHandler(this.radioButton_CheckedChanged);&lt;br /&gt;			this.radDataAdapter.CheckedChanged -= new System.EventHandler(this.radioButton_CheckedChanged);&lt;br /&gt;			radExecuteScalar.Checked = false;&lt;br /&gt;			radDataAdapter.Checked = false;&lt;br /&gt;			((RadioButton)sender).Checked = true;&lt;br /&gt;			this.radDataAdapter.CheckedChanged += new System.EventHandler(this.radioButton_CheckedChanged);&lt;br /&gt;			this.radExecuteScalar.CheckedChanged += new System.EventHandler(this.radioButton_CheckedChanged);&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Add some code to the run button event handler to choose which method to run based on the radio button checked and you are done.  &lt;/li&gt;&lt;li&gt;Try executing &lt;code&gt;select * from sysobjects&lt;/code&gt; with the new code.  What happens when you try it with the old code?  How about when you try and execute a stored procedure like &lt;code&gt;sp_who&lt;/code&gt;?&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;a href="http://smithmier.com/SqlServerTester.zip"&gt;project files and source code&lt;/a&gt;</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:csharp4u:461</id>
    <link rel="alternate" type="text/html" href="http://csharp4u.livejournal.com/461.html"/>
    <link rel="self" type="text/xml" href="http://csharp4u.livejournal.com/data/atom/?itemid=461"/>
    <title>Isolated Storage</title>
    <published>2005-10-11T19:26:34Z</published>
    <updated>2005-10-12T02:15:19Z</updated>
    <category term="c# isolatedstorage security examples"/>
    <content type="html">&lt;h3&gt;Isolated storage is a managed disk access method encompasing security&lt;/h3&gt;&lt;br /&gt;“Isolated storage is a data storage mechanism that provides isolation and safety by defining standardized ways of associating code with saved data.”&lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconIsolatedStorage.asp"&gt;&lt;sup&gt;1&lt;/sup&gt;&lt;/a&gt;   Isolated storage files are stored within the private data of the user running the application.  In fact, the framework determines the location of the file system available to your program (this works sort of like a chroot padded cell in Linux land) in isolated storage depending on what IsolatedStorageScope you define when you get access to the store.  A single program can open several files with the same name in many different locations by using differently scoped stores.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Using isolated storage conforms to least privilege principals&lt;/h3&gt;&lt;br /&gt;Why should you care about isolated storage?  It will be much more important with the release of Vista and the greater integration of Code Access Security (CAS)&lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconcodeaccesssecurity.asp"&gt;&lt;sup&gt;2&lt;/sup&gt;&lt;/a&gt;  and User Account Protection (UAP)&lt;a href="http://msdn.microsoft.com/windowsvista/security/"&gt;&lt;sup&gt;3&lt;/sup&gt;&lt;/a&gt; .  These two technologies allow Administrators and Users fine grained control on what resources a program has access to.  Using the development practice of “Least Privilege”&lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncode/html/secure06112002.asp"&gt;&lt;sup&gt;4&lt;/sup&gt;&lt;/a&gt; , we should not request access to the file system to simply store user configuration information.  Likewise, accessing the registry (which has been a favorite place for storing configuration information) is problematic to implement and requires privileges not granted to programs by default, thus violating least privilege again.  Vista does allow elevation of rights for users who have administrative privileges but asking the user to elevate each time a setting changed wouldn’t be a very good user experience.&lt;br /&gt;&lt;br /&gt;&lt;a name="cutid1"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h3&gt;A simple Hello World program using isolated storage&lt;/h3&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;pre&gt;
using System;
using System.IO;
using System.IO.IsolatedStorage;

namespace SimplestIsolatedStorageExample
{
    class Class1
    {
        [STAThread]
        static void Main(string[] args)
        {
            IsolatedStorageFile isolatedStorageFile =
                IsolatedStorageFile.GetUserStoreForAssembly();
                StreamWriter sw = new StreamWriter(new 
                    IsolatedStorageFileStream(
                        "HelloWorld.txt",
                        FileMode.OpenOrCreate,
                        isolatedStorageFile)
                        );
            sw.Write("Howdy y'all");
            sw.Close();
        }
    }
}
&lt;/pre&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;This program uses the call to &lt;code&gt;IsolatedStorageFile.GetUserStoreForAssembly();&lt;/code&gt; to open up a store in the &lt;code&gt;User/Assembly&lt;/code&gt; scope (which is the default).  This is a shortcut for &lt;code&gt;IsolatedStorageFile.GetStore(IsolatedStorageScope.Assembly | IsolatedStorageScope.User, null, null);&lt;/code&gt;.  The &lt;code&gt;IsolatedStorageScope&lt;/code&gt; enum defines: &lt;code&gt;Assembly&lt;/code&gt;, &lt;code&gt;Domain&lt;/code&gt;, &lt;code&gt;None&lt;/code&gt;, &lt;code&gt;Roaming&lt;/code&gt;, and &lt;code&gt;User&lt;/code&gt;.  All defined scopes must include &lt;code&gt;Assembly&lt;/code&gt; and &lt;code&gt;User&lt;/code&gt;.  &lt;br /&gt;&lt;h3&gt;A more thorough example of the use of scope in isolated storage&lt;/h3&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;pre&gt;
using System;
using System.IO;
using System.IO.IsolatedStorage;

namespace IsolatedStorageScopeExample
{
    class Class1
    {
        [STAThread]
        static void Main(string[] args)
        {
            IsolatedStorageFile isolatedStorageFile; 
            string fileName;
            isolatedStorageFile =
                IsolatedStorageFile.GetStore(
                    IsolatedStorageScope.Assembly 
                    | IsolatedStorageScope.User
                    , null, null);
            fileName = "Assembly_User";
            WriteFile(fileName, isolatedStorageFile);
            isolatedStorageFile =
                IsolatedStorageFile.GetStore(
                    IsolatedStorageScope.Assembly 
                    | IsolatedStorageScope.User 
                    | IsolatedStorageScope.Domain
                    , null, null);
            fileName = "Assembly_User_Domain";
            WriteFile(fileName, isolatedStorageFile);
            isolatedStorageFile =
                IsolatedStorageFile.GetStore(
                    IsolatedStorageScope.Assembly 
                    | IsolatedStorageScope.User 
                    | IsolatedStorageScope.Roaming
                    , null, null);
            fileName = "Assembly_User_Roaming";
            WriteFile(fileName, isolatedStorageFile);
            isolatedStorageFile =
                IsolatedStorageFile.GetStore(
                    IsolatedStorageScope.Assembly 
                    | IsolatedStorageScope.User 
                    | IsolatedStorageScope.Domain 
                    | IsolatedStorageScope.Roaming
                    , null, null);
            fileName = "Assembly_User_Domain_Roaming";
            WriteFile(fileName, isolatedStorageFile);
        }

        private static void WriteFile(
            string fileName, 
            IsolatedStorageFile isolatedStorageFile)
        {
            StreamWriter sw = new StreamWriter(new 
                    IsolatedStorageFileStream(
                        fileName+".txt",
                        FileMode.OpenOrCreate,
                        isolatedStorageFile));
            sw.Write("Howdy y'all out there in "
                    +fileName.Replace("_"," ")+" land.");
            sw.Close();
        }
    }
}
&lt;/pre&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;This program opens up four files (one in each available scope) and writes a little message in each.  The files are located in different places depending on the scope and OS you are running.  &lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Where the files are stored&lt;/h3&gt;&lt;br /&gt;On my XP Pro system, the default location (&lt;code&gt;Assembly&lt;/code&gt;/&lt;code&gt;User&lt;/code&gt;) is stored in:&lt;br /&gt;&lt;code&gt;&lt;pre&gt;C:\Documents and Settings\lsmithmier\Local Settings\Application Data\IsolatedStorage\&lt;/pre&gt;&lt;/code&gt;&lt;br /&gt;If you dig into the appropriate directory for your OS, you will be able to find the files created in the above examples.  A table with all of the locations listed can be found in the MSDN library (&lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconintroductiontoisolatedstorage.asp"&gt;http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconintroductiontoisolatedstorage.asp&lt;/a&gt;).&lt;br /&gt;&lt;br /&gt;A WinForms program that allows you to play with scope interactively, along with projects containing the above console applications can be downloaded from &lt;a href="http://Smithmier.com/IsolatedStorage.zip"&gt;http://Smithmier.com/IsolatedStorage.zip&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Sources:&lt;br /&gt;1 &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconIsolatedStorage.asp"&gt;http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconIsolatedStorage.asp&lt;/a&gt;&lt;br /&gt;2 &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconcodeaccesssecurity.asp"&gt;http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconcodeaccesssecurity.asp&lt;/a&gt;&lt;br /&gt;3 &lt;a href="http://msdn.microsoft.com/windowsvista/security/"&gt;http://msdn.microsoft.com/windowsvista/security/&lt;/a&gt;&lt;br /&gt;4 &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncode/html/secure06112002.asp"&gt;http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncode/html/secure06112002.asp&lt;/a&gt;</content>
  </entry>
</feed>
