title: Nodejs Absolute file: url in readfile
body: <p>I'm trying to download attachments from email using imap to my disk. I'm able to connect to my email host and download the attachments. But I want to download the attachments to a custom location. Right now its being downloaded to my _dirname.</p>
  
  <p>Below is my code to get the attachments:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function buildAttMessageFunction(attachment) {
              var filename = attachment.params.name;
              return function (msg, seqno) {
               var prefix = '(#' + seqno + ') ';
      msg.on('body', function(stream, info) {
        //Create a write stream so that we can stream the attachment to file;
        console.log(prefix + 'Streaming this attachment to file', filename, info);
        var writeStream = fs.createWriteStream('F:/'+ filename);
        //writeStream.path = '../'+filename;
        console.log(writeStream)
        writeStream.on('finish', function() {
          console.log(prefix + 'Done writing to file %s',filename);
        });
        stream.pipe(writeStream);
        });
      msg.once('end', function() {
        console.log(prefix + 'Finished attachment %s', filename);
      });
    };
  } </code></pre>
  </div>
  </div>
  </p>
  
  <p>The above function works and it saves my attachment to my _dirname. How can I save this document to my C: drive? I tried changing the file name to <code>file:///C:/' +attachment.params.name</code> and I'm getting the foloowing error:</p>
  
  <blockquote>
    <p>Error: ENOENT: no such file or directory, open
    'file:///C:/filenane.xlsx'</p>
  </blockquote>
  
  <p>I tried declaring writestream as <code>var writeStream = fs.createWriteStream('file:///C:/'+filename)</code> and getting the same error.</p>
  
  <p>I also tried the above 2 with no 'file:' prefix. That didn't work either. How can I get thid done?</p>