Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy does this code throws NullReferenceException?
    primarykey
    data
    text
    <pre><code>public FileEntry ReadFileConfiguration(string id) { string configurationPath = "conf.xml"; XDocument data = XDocument.Load(configurationPath); return (from c in data.Descendants("file") where (c.Attribute("Id") != null &amp;&amp; c.Attribute("Id").Value.Equals(id)) select new FileEntry() { Name = c.Element("Name").Value, Path = c.Element("Path").Value, SheduledTime = Convert.ToDateTime(c.Element("SheduledTime").Value), Size = (long)Convert.ToDouble( c.Element("Size").Value), IsFolder = Convert.ToBoolean( c.Element("IsFolder").Value), LastAccess = Convert.ToDateTime(c.Element("LastAccess").Value), DoEncrypt = Convert.ToBoolean( c.Element("DoEncrypt").Value) }).First(); } </code></pre> <p>Main program is:</p> <pre><code>main() { string id = "C:\\Users\\Radhesh\\Documents\\Visual Studio 2008\\Projects\\Rme\\Rme\\test.txt"; ReadFileConfiguration(id); } </code></pre> <p>My XML page is:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt; &lt;Files&gt; &lt;file Id="C:\Users\Radhesh\Documents\Visual Studio 2008\Projects\Rme\Rme\test.txt"&gt; &lt;Name&gt;test.txt&lt;/Name&gt; &lt;Path&gt;C:\Users\Radhesh\Documents\Visual Studio 2008\Projects\Rme\Rme\test.txt&lt;/Path&gt; &lt;IsFolder&gt;False&lt;/IsFolder&gt; &lt;DoEncrypt&gt;True&lt;/DoEncrypt&gt; &lt;Size&gt;0&lt;/Size&gt; &lt;LastAcess&gt;7/9/2011 11:35:53 PM&lt;/LastAcess&gt; &lt;SheduledTime&gt;7/10/2011 1:59:20 PM&lt;/SheduledTime&gt; &lt;/file&gt; &lt;/Files&gt; </code></pre> <p>My class:</p> <pre><code>class FileEntry { public string Name { get;set;} public string Path { get; set; } public bool IsFolder { get; set; } public long Size { get;set; } public DateTime LastAccess { get;set; } public DateTime SheduledTime { get; set; } public bool DoEncrypt { get; set; } } </code></pre> <p>Please, can anyone help?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload