Reading a configuration file in c# The configuration file of my app is similar to,

&lt;?xml version="1.0" encoding="utf-8" ?&gt;
&lt;Items&gt;
      &lt;Item Name="Coffee"
            Cost="10"
            Image="itemCoffee.png" /&gt;
      &lt;Item Name="Tea"
            Cost="10"
            Image="itemTea.png" /&gt;
      &lt;Item Name="Vada"
            Cost="10"
            Image="itemVada.png" /&gt;
  &lt;/Items&gt;


Just trying to read the above small configuration file and I wrote this method.

public static class Configuration
{
    public static T DeSerialize&lt;T&gt;(string filePath)
    {
        if (!System.IO.File.Exists(filePath))
        {
            throw new System.IO.FileNotFoundException(filePath);
        }

        var serializer = new System.Xml.Serialization.XmlSerializer(T);
        return (T)serializer.Deserialize(new FileStream(filePath, FileMode.Open));
    }
}



Where should I use using in this code? (Because, I never ever dispose the new FileStream that I wrote in this method)
Is this an overkill for reading this simple xml file?
I would definitely wrap the FileStream object into a using clause like this:

using (Stream reader = new FileStream(filePath, FileMode.Open))
{
  var serializer = new System.Xml.Serialization.XmlSerializer(typeof(T));
  return (T)serializer.Deserialize(reader);
}


This way the Dispose method of the FileStream gets called immediately. Otherwise it will be delayed until the FileStream object gets garbage collected. This may not be a big problem in practice in simple applications where you read the configuration only once but is good practice to do it anyway.
Also note that you have to use XmlSerializer(typeof(T)) instead of XmlSerializer(T).
My opinion is that it is overkill to create a generic method if you have only one kind of configuration file in your app. This method might be hard to read for a maintainer who is not sufficiently comfortable with generics and it has no benefit in making your code DRY-er if you have only one type of configuration file.