title: How can I read a file which will be upload from a form in .Net Core API?
body: <p>I create a method in my .Net Core API which will upload a file.</p>
  
  <pre><code>[HttpPost]
  public async Task&lt;IActionResult&gt; ReadFile(IFormFile file)
  {
      return BadRequest(file);
  }
  </code></pre>
  
  <p>I do a <code>return BadRequest(file)</code> in order to read what it send me on <strong>postman</strong>.</p>
  
  <p>The result is this :</p>
  
  <pre><code>{
      "contentDisposition": "form-data; name=\"file\"; filename=\"data.dat\"",
      "contentType": "application/octet-stream",
      "headers": {
          "Content-Disposition": [
              "form-data; name=\"file\"; filename=\"data.dat\""
          ],
          "Content-Type": [
              "application/octet-stream"
          ]
      },
      "length": 200,
      "name": "file",
      "fileName": "data.dat"
  </code></pre>
  
  <p>}</p>
  
  <p>I see on Microsoft documentation this : </p>
  
  <pre><code>using (StreamReader sr = new StreamReader("TestFile.txt"))
  {
      // Read the stream to a string, and write the string to the console.
          String line = sr.ReadToEnd();
          Console.WriteLine(line);
  }
  </code></pre>
  
  <p>But the user will have to choose a file to read in it, the application won't have to go in a folder and read a file.</p>
  
  <p>It is possible to do this ? And can I have some link to help me to do this ?</p>
  
  <p><strong>Update</strong> </p>
  
  <p>I want to the method ReadFile read the content of my file which will be upload thinks to a form.</p>
  
  <p>So I will have a string which will have the content of my file and after that I will can all I wanted to do in this file.</p>
  
  <p>For example I have a file and in this file it is wrote <strong>LESSON</strong>, with the method <strong>ReadFile</strong> I will get the word lesson in a string.</p>