title: How to get a file from a filepath
body: <p>I have a string array fileContentArray, which contains a list of filepath.</p>
  
  <pre><code>fileContentArray[0]    D:\Downloads\KuGou\1.mp3
  fileContentArray[1]    E:\Downloads\2.mp3
  fileContentArray[2]    F:\KuGou\3.mp3
  </code></pre>
  
  <p>And </p>
  
  <pre><code>List&lt;StorageFile&gt; files = new List&lt;StorageFile&gt;();
  </code></pre>
  
  <p>I want to add the files into the list</p>
  
  <pre><code>private async Task ReadListAsync()
          {
              StorageFolder sFolder = ApplicationData.Current.LocalFolder;
              StorageFile sf = await sFolder.CreateFileAsync("List.txt", CreationCollisionOption.OpenIfExists);
              using (IRandomAccessStream readStream = await sf.OpenAsync(FileAccessMode.Read))
              {
                  using (DataReader dataReader = new DataReader(readStream))
                  {
                      UInt64 size = readStream.Size;
                      if (size &lt;= UInt32.MaxValue)
                      {
                          UInt32 numBytesLoaded = await dataReader.LoadAsync((UInt32)size);
                          string fileContent = dataReader.ReadString(numBytesLoaded);
                          string[] fileContentArray = fileContent.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                          List&lt;StorageFile&gt; files = new List&lt;StorageFile&gt;();
                          foreach (string filepath in fileContentArray)
                          {
                              StorageFile sff = await StorageFile.GetFileFromPathAsync(filepath);
                              files.Add(sff);
                          }
  
                          await AddStorageFilestoList(files);
                      }
                  }
              }
          }
  </code></pre>
  
  <p>But when I run the code, it tells me wrong while GetFileFromPathAsync.</p>
  
  <blockquote>
    <p>{System.UnauthorizedAccessException: 拒绝访问。</p>
    
    <p>at
    System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
    task)    at
    System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
    task)    at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() 
    at MP3Tag.Views.MasterDetailPage.d__31.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---    at
    System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
    task)    at
    System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
    task)    at System.Runtime.CompilerServices.TaskAwaiter.GetResult()<br>
    at MP3Tag.Views.MasterDetailPage.d__10.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---    at
    System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
    task)    at
    System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
    task)    at System.Runtime.CompilerServices.TaskAwaiter.GetResult()<br>
    at MP3Tag.Views.MasterDetailPage.d__9.MoveNext()}</p>
  </blockquote>
  
  <p>In my another app, the almost same code, works.</p>
  
  <pre><code>string strLastFile = (Application.Current as App).localSettings.Values["LastFile"] as string;
                  if (strLastFile != null)
                  {
                      try
                      {
                          file = await StorageFile.GetFileFromPathAsync(strLastFile);
                          await LoadFileAsync(file);
                      }
                      catch
                      {
                          //文件不存 
                      }
                  }
  </code></pre>
  
  <p>It's just a local app, read a txt file, which contains a list of filepath.
  I want to show some info about the files.
  How to use it in the correct way?
  Thx.</p>