title: xp_cmdshell write file directory to a text file
body: <p>how do I write my file directory to a text file? The directory I want to use is C:\</p>
  
  <p>The code I have now is</p>
  
  <pre><code>exec xp_cmdshell 'dir *.exe &amp; echo &gt; file_directory.txt';--
  </code></pre>
  
  <p>It's not writing to a file though. Do I need to say this...</p>
  
  <pre><code>exec xp_cmdshell 'cd c: \ &amp; dir *.exe &amp; echo &gt; file_directory.txt';--
  </code></pre>