Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

Read xml file and Deserialize using C#

public static T GetSavedOptions<T>(string filename) where T : class
{
    try
    {
        var xs = new XmlSerializer(typeof(T));
        var filePath = GetOptionPath(filename);
        using (var userData = new FileStream(filePath, FileMode.Open, FileAccess.Read))
        {
            return xs.Deserialize(userData) as T;
        }
    }
    catch (Exception ex)
    {
        throw ex;
    }
}
Source by json2csharp.com #
 
PREVIOUS NEXT
Tagged: #Read #xml #file #Deserialize
ADD COMMENT
Topic
Name
9+1 =