title: R: Got problems in reading text file
body: <p>I want to read text file in R. The code used to work. But when I want to retest it, it didn't.</p>
  
  <pre><code>#There are several text files in file'Obama' and file 'Romney'
  candidates&lt;-c("Obama","Romney")
  pathname&lt;-"C:/txt"
  s.dir&lt;-sprintf("%s/%s",pathname,candidates)
  article&lt;-Corpus(DirSource(directory=s.dir,encoding="ANSI"))
  </code></pre>
  
  <p>The error it displayed is </p>
  
  <pre><code>Error in iconv(readLines(x, warn = FALSE), encoding, "UTF-8", "byte") : 
  unsupported conversion from 'ANSI' to 'UTF-8' in codepage 936
  </code></pre>
  
  <p>Also, when I use the code below to try to read a single text file:</p>
  
  <pre><code>m&lt;-"C:/txt/Romney/1.txt"
  cc&lt;-Corpus(DirSource(directory=m,encoding="ANSI"))
  </code></pre>
  
  <p>It displayed:</p>
  
  <pre><code>Error in DirSource(directory = m, encoding = "ANSI") : empty directory
  </code></pre>
  
  <p>The file path exist, why I met this problem?</p>