title: Logon failure: unknown user name or bad password. FTP with C#
body: <p>I am trying to access an FTP server that is outside our network to get a CSV file. Here is the code that I am using</p>
  
  <pre><code>string XMLPATH = @"\\server\file.csv";
  FileWebRequest request = (FileWebRequest)FileWebRequest.Create(XMLPATH);
  request.Credentials = new NetworkCredential("admin", "password");
  FileWebResponse response = request.GetResponse() as FileWebResponse;
  Stream stReader = response.GetResponseStream();
  </code></pre>
  
  <p>When I run this through my console app, I get this message.</p>
  
  <pre><code>Logon failure: unknown user name or bad password
  </code></pre>
  
  <p>If I go to the server location to get the file in Windows Explorer, I am able to login just fine and retrieve the file. After that, my application can access the file just fine. I read this previous stack thread</p>
  
  <p><a href="https://stackoverflow.com/questions/10242990/logon-failure-unknown-user-name-or-bad-password-but-i-am-using-the-right-usern">Logon failure: unknown user name or bad password? But I am using the right username and password</a></p>
  
  <p>And I added this to my config</p>
  
  <pre><code>&lt;system.net&gt;
   &lt;defaultProxy useDefaultCredentials="false"&gt;
    &lt;proxy usesystemdefault="True"/&gt;
   &lt;/defaultProxy&gt;
  &lt;/system.net&gt;
  </code></pre>
  
  <p>And that changes nothing. I have also tried to add my domain to the Credentials Constructor, but that does not fix anything either. This connection needs to be done as a client application, so the previous post is a little different than mine. Any help would be greatly appreciated. Thanks </p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Because I was curious, I ran a Wireshark trace on the call for both the Windows Explorer and my application's request. When using explorer, it send the request using the proper credentials. However when I use the application, it sends the request as the logged in name of my machine (aka my user id). Why is it when I send the request credentials in the request, it still defaults to the logged in user? Is there a setting I have to configure for this?</p>