title: How to solve the problem of Permission denied while reading a file from UWP application?
body: <p>I am trying to reading a .txt file of C or D drive in a UWP application. It is ok, when I declare the local variable for file name in assets. But it's filed to read file from others directory or drives as well.</p>
  
  <p>I have tried like the code portion below:</p>
  
  <pre class="lang-cs prettyprint-override"><code>try
  {
      String FileName = "C:\Users\abc\Documents\file.txt";
      // Read the file and display it line by line.  
      string[] lines = File.ReadAllLines(FileName);
      foreach (string inputLine in lines)
      {
          List&lt;String&gt; dummyList = new List&lt;String&gt;();
          String[] lineList = inputLine.Split(", ");
  
          foreach (var item in lineList)
          {
              dummyList.Add(item);
              //Debug.WriteLine(item);
          }
          mainList.Add(dummyList);
      }
  
      //file.Close();
  }
  catch (Exception ex)
  {
      Debug.WriteLine("[DEBUG] " + ex);
  }
  </code></pre>
  
  <p>The "file.txt" has both read and write permission locally for all users and applications. It has done from the file.txt properties in windows.</p>
  
  <p>Exception is like below:</p>
  
  <pre class="lang-py prettyprint-override"><code>System.UnauthorizedAccessException: Access to the path 'C:\Users\abc\Documents\file.txt' is denied.
     at System.IO.FileStream.ValidateFileHandle(SafeFileHandle fileHandle)
     at System.IO.FileStream.CreateFileOpenHandle(FileMode mode, FileShare share, FileOptions options)
     at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
     at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize)
     at System.IO.File.InternalReadAllLines(String path, Encoding encoding)
     at Localizer.Data.StringDataText.StringDataInitialize()
  </code></pre>