title: JsonConvert.DeserializeObject() throwing System.ArgumentNullException: 'Path cannot be null. Parameter name: path' exception. Why?
body: <p>My class structure is as follows:</p>
  <pre><code>class AppDetails
  {
      public String companyName { get; set; }
      public String applicationName { get; set; }
      public String version { get; set; }
      public List&lt;File_&gt; fileObjectList { get; set; }
  
      public AppDetails(String cName, String aName, String v)
      {
          companyName = cName;
          applicationName = aName;
          version = v;
      }
  }
  
  class File_
  {
      public String filePath { get; set; }
      public FileRecord fileRecord { get; set; }
      public File_(String parent_, String filepath_, Boolean Ignored)
      {
          filePath = filepath_;
          fileRecord = new FileRecord(parent_ + filePath, Ignored);
      }
  }
  
  class FileRecord
  {
      public Boolean ignored { get; set; }
      public String MD5Checksum { get; set; }
      public int version { get; set; }
  
      public FileRecord(String filePath, Boolean ignored_)
      {
          ignored = ignored_;
          if (ignored)
          {
              MD5Checksum = null;
          }
          else
          {
              MD5Checksum = CalculateMD5(filePath);
              version = 0;
          }
      }
  
      static string CalculateMD5(string filePath)
      {
          var md5 = MD5.Create();
          var stream = File.OpenRead(filePath);
          var hash = md5.ComputeHash((System.IO.Stream)stream);
          return BitConverter.ToString(hash).Replace(&quot;-&quot;, &quot;&quot;).ToLowerInvariant();
  
      }
  
  }
  </code></pre>
  <p>I generated Json file using these classes. But when I try to initialize an object with the said JSON file, it throws System.ArgumentNullException: 'Path cannot be null. Parameter name: path' exception.
  This is the function that is supposed to return the object.</p>
  <pre><code>AppDetails ReadJsonFile()
      {
          using (StreamReader r = File.OpenText(parent + &quot;\\AllFilesList.json&quot;))
          {
              string json = r.ReadToEnd();
              var result = JsonConvert.DeserializeObject&lt;AppDetails&gt;(json);
              return result;
          }
      }
  </code></pre>
  <p>I tried generating the classes from JSON using online class generators and it matches my class structure. Exception is thrown on this line:</p>
  <pre><code>var result = JsonConvert.DeserializeObject&lt;AppDetails&gt;(json);
  </code></pre>
  <p>Json string is getting loaded with the content from the file just fine(as can be seen from the watch). I couldn't find anything about Path issues related to JsonConvert.DeserializeObject. Most previous questions seems to be related to value errors.</p>
  <p>EDIT: Serialization Code</p>
  <pre><code>void JsonWriter(AppDetails appDetails, String filename)
      {
          string path = parent + &quot;\\&quot; + filename + &quot;.json&quot;;
          File.Delete(path);
          string json = JsonConvert.SerializeObject(appDetails);
          using (var tw = new StreamWriter(path, true))
          {
              tw.WriteLine(json.ToString());
              tw.Close();
          }
      }
  </code></pre>
  <p>Sample Json File:</p>
  <pre><code>{&quot;companyName&quot;:&quot;Home&quot;,&quot;applicationName&quot;:&quot;Test&quot;,&quot;version&quot;:&quot;V5.0.1&quot;,&quot;fileObjectList&quot;:[{&quot;filePath&quot;:&quot;\\bug-tracker.exe&quot;,&quot;fileRecord&quot;:{&quot;ignored&quot;:false,&quot;MD5Checksum&quot;:&quot;a5254a813a040b429f2288df737a8b9f&quot;,&quot;version&quot;:0}},{&quot;filePath&quot;:&quot;\\bug-tracker.exe.config&quot;,&quot;fileRecord&quot;:{&quot;ignored&quot;:false,&quot;MD5Checksum&quot;:&quot;e5c3e9137dc8fadb57dfc27b0ba6855c&quot;,&quot;version&quot;:0}},{&quot;filePath&quot;:&quot;\\bug-tracker.pdb&quot;,&quot;fileRecord&quot;:{&quot;ignored&quot;:false,&quot;MD5Checksum&quot;:&quot;9a9dfda29dcaacae82cba7bd7aa97ffa&quot;,&quot;version&quot;:0}},{&quot;filePath&quot;:&quot;\\Caliburn.Micro.dll&quot;,&quot;fileRecord&quot;:{&quot;ignored&quot;:false,&quot;MD5Checksum&quot;:&quot;aa5f96c02b08d9b33322f3024058dd91&quot;,&quot;version&quot;:0}},{&quot;filePath&quot;:&quot;\\Caliburn.Micro.Platform.Core.dll&quot;,&quot;fileRecord&quot;:{&quot;ignored&quot;:false,&quot;MD5Checksum&quot;:&quot;ab7867bd44b59879a59b5cb968e15668&quot;,&quot;version&quot;:0}},{&quot;filePath&quot;:&quot;\\Caliburn.Micro.Platform.Core.xml&quot;,&quot;fileRecord&quot;:{&quot;ignored&quot;:false,&quot;MD5Checksum&quot;:&quot;cdfcbbf70a9a62b92e82a953ab9e7e30&quot;,&quot;version&quot;:0}},{&quot;filePath&quot;:&quot;\\Caliburn.Micro.Platform.dll&quot;,&quot;fileRecord&quot;:{&quot;ignored&quot;:false,&quot;MD5Checksum&quot;:&quot;a52bdecbc1b7625cb13c9385fad4231b&quot;,&quot;version&quot;:0}},{&quot;filePath&quot;:&quot;\\Caliburn.Micro.Platform.xml&quot;,&quot;fileRecord&quot;:{&quot;ignored&quot;:false,&quot;MD5Checksum&quot;:&quot;09f258a3aeca7285355d82a66dda2176&quot;,&quot;version&quot;:0}},{&quot;filePath&quot;:&quot;\\Caliburn.Micro.xml&quot;,&quot;fileRecord&quot;:{&quot;ignored&quot;:false,&quot;MD5Checksum&quot;:&quot;c87ec582a4bfcf2e79e517c689441def&quot;,&quot;version&quot;:0}},{&quot;filePath&quot;:&quot;\\MaterialDesignColors.dll&quot;,&quot;fileRecord&quot;:{&quot;ignored&quot;:false,&quot;MD5Checksum&quot;:&quot;ad729352a9088b889cc0c4dc7542dcb6&quot;,&quot;version&quot;:0}},{&quot;filePath&quot;:&quot;\\MaterialDesignColors.pdb&quot;,&quot;fileRecord&quot;:{&quot;ignored&quot;:false,&quot;MD5Checksum&quot;:&quot;7ba70b23e22db9ac155e190860d9a5ec&quot;,&quot;version&quot;:0}},{&quot;filePath&quot;:&quot;\\MaterialDesignThemes.Wpf.dll&quot;,&quot;fileRecord&quot;:{&quot;ignored&quot;:false,&quot;MD5Checksum&quot;:&quot;e4c790d3af41620dc5ad513ae7fcadac&quot;,&quot;version&quot;:0}},{&quot;filePath&quot;:&quot;\\MaterialDesignThemes.Wpf.pdb&quot;,&quot;fileRecord&quot;:{&quot;ignored&quot;:false,&quot;MD5Checksum&quot;:&quot;f8113c8ea54896b8150db8e7ebd506ef&quot;,&quot;version&quot;:0}},{&quot;filePath&quot;:&quot;\\MaterialDesignThemes.Wpf.xml&quot;,&quot;fileRecord&quot;:{&quot;ignored&quot;:false,&quot;MD5Checksum&quot;:&quot;49717f8130b7529ee51fb6bc13f79aa4&quot;,&quot;version&quot;:0}},{&quot;filePath&quot;:&quot;\\ShowMeTheXAML.dll&quot;,&quot;fileRecord&quot;:{&quot;ignored&quot;:false,&quot;MD5Checksum&quot;:&quot;040b9e80820553a55f13ac19c2036367&quot;,&quot;version&quot;:0}},{&quot;filePath&quot;:&quot;\\System.Windows.Interactivity.dll&quot;,&quot;fileRecord&quot;:{&quot;ignored&quot;:false,&quot;MD5Checksum&quot;:&quot;580244bc805220253a87196913eb3e5e&quot;,&quot;version&quot;:0}}]}
  </code></pre>
  <p>Edit 2: Json String from watch</p>
  <pre><code>&quot;{\&quot;companyName\&quot;:\&quot;Home\&quot;,\&quot;applicationName\&quot;:\&quot;Test\&quot;,\&quot;version\&quot;:\&quot;V5.0.1\&quot;,\&quot;fileObjectList\&quot;:[{\&quot;filePath\&quot;:\&quot;\\\\bug-tracker.exe\&quot;,\&quot;fileRecord\&quot;:{\&quot;ignored\&quot;:false,\&quot;MD5Checksum\&quot;:\&quot;a5254a813a040b429f2288df737a8b9f\&quot;,\&quot;version\&quot;:0}},{\&quot;filePath\&quot;:\&quot;\\\\bug-tracker.exe.config\&quot;,\&quot;fileRecord\&quot;:{\&quot;ignored\&quot;:false,\&quot;MD5Checksum\&quot;:\&quot;e5c3e9137dc8fadb57dfc27b0ba6855c\&quot;,\&quot;version\&quot;:0}},{\&quot;filePath\&quot;:\&quot;\\\\bug-tracker.pdb\&quot;,\&quot;fileRecord\&quot;:{\&quot;ignored\&quot;:false,\&quot;MD5Checksum\&quot;:\&quot;9a9dfda29dcaacae82cba7bd7aa97ffa\&quot;,\&quot;version\&quot;:0}},{\&quot;filePath\&quot;:\&quot;\\\\Caliburn.Micro.dll\&quot;,\&quot;fileRecord\&quot;:{\&quot;ignored\&quot;:false,\&quot;MD5Checksum\&quot;:\&quot;aa5f96c02b08d9b33322f3024058dd91\&quot;,\&quot;version\&quot;:0}},{\&quot;filePath\&quot;:\&quot;\\\\Caliburn.Micro.Platform.Core.dll\&quot;,\&quot;fileRecord\&quot;:{\&quot;ignored\&quot;:false,\&quot;MD5Checksum\&quot;:\&quot;ab7867bd44b59879a59b5cb968e15668\&quot;,\&quot;version\&quot;:0}},{\&quot;filePath\&quot;:\&quot;\\\\Caliburn.Micro.Platform.Core.xml\&quot;,\&quot;fileRecord\&quot;:{\&quot;ignored\&quot;:false,\&quot;MD5Checksum\&quot;:\&quot;cdfcbbf70a9a62b92e82a953ab9e7e30\&quot;,\&quot;version\&quot;:0}},{\&quot;filePath\&quot;:\&quot;\\\\Caliburn.Micro.Platform.dll\&quot;,\&quot;fileRecord\&quot;:{\&quot;ignored\&quot;:false,\&quot;MD5Checksum\&quot;:\&quot;a52bdecbc1b7625cb13c9385fad4231b\&quot;,\&quot;version\&quot;:0}},{\&quot;filePath\&quot;:\&quot;\\\\Caliburn.Micro.Platform.xml\&quot;,\&quot;fileRecord\&quot;:{\&quot;ignored\&quot;:false,\&quot;MD5Checksum\&quot;:\&quot;09f258a3aeca7285355d82a66dda2176\&quot;,\&quot;version\&quot;:0}},{\&quot;filePath\&quot;:\&quot;\\\\Caliburn.Micro.xml\&quot;,\&quot;fileRecord\&quot;:{\&quot;ignored\&quot;:false,\&quot;MD5Checksum\&quot;:\&quot;c87ec582a4bfcf2e79e517c689441def\&quot;,\&quot;version\&quot;:0}},{\&quot;filePath\&quot;:\&quot;\\\\MaterialDesignColors.dll\&quot;,\&quot;fileRecord\&quot;:{\&quot;ignored\&quot;:false,\&quot;MD5Checksum\&quot;:\&quot;ad729352a9088b889cc0c4dc7542dcb6\&quot;,\&quot;version\&quot;:0}},{\&quot;filePath\&quot;:\&quot;\\\\MaterialDesignColors.pdb\&quot;,\&quot;fileRecord\&quot;:{\&quot;ignored\&quot;:false,\&quot;MD5Checksum\&quot;:\&quot;7ba70b23e22db9ac155e190860d9a5ec\&quot;,\&quot;version\&quot;:0}},{\&quot;filePath\&quot;:\&quot;\\\\MaterialDesignThemes.Wpf.dll\&quot;,\&quot;fileRecord\&quot;:{\&quot;ignored\&quot;:false,\&quot;MD5Checksum\&quot;:\&quot;e4c790d3af41620dc5ad513ae7fcadac\&quot;,\&quot;version\&quot;:0}},{\&quot;filePath\&quot;:\&quot;\\\\MaterialDesignThemes.Wpf.pdb\&quot;,\&quot;fileRecord\&quot;:{\&quot;ignored\&quot;:false,\&quot;MD5Checksum\&quot;:\&quot;f8113c8ea54896b8150db8e7ebd506ef\&quot;,\&quot;version\&quot;:0}},{\&quot;filePath\&quot;:\&quot;\\\\MaterialDesignThemes.Wpf.xml\&quot;,\&quot;fileRecord\&quot;:{\&quot;ignored\&quot;:false,\&quot;MD5Checksum\&quot;:\&quot;49717f8130b7529ee51fb6bc13f79aa4\&quot;,\&quot;version\&quot;:0}},{\&quot;filePath\&quot;:\&quot;\\\\ShowMeTheXAML.dll\&quot;,\&quot;fileRecord\&quot;:{\&quot;ignored\&quot;:false,\&quot;MD5Checksum\&quot;:\&quot;040b9e80820553a55f13ac19c2036367\&quot;,\&quot;version\&quot;:0}},{\&quot;filePath\&quot;:\&quot;\\\\System.Windows.Interactivity.dll\&quot;,\&quot;fileRecord\&quot;:{\&quot;ignored\&quot;:false,\&quot;MD5Checksum\&quot;:\&quot;580244bc805220253a87196913eb3e5e\&quot;,\&quot;version\&quot;:0}}]}\r\n&quot;
  </code></pre>