title: FTP The remote server returned an error: (530) Not logged in
body: <p>I created an FTP, and I want to read some data using C# code. When the FTP has no username/password access, everything works perfectly. But when I put username and password, I get <code>The remote server returned an error: (530) Not logged in</code>.</p>
  <p>I tried all the questions on Stack Overflow and the internet like using <code>.Normalize()</code>, and using <code>@username</code>, but I keep getting that error.</p>
  <p>this is my code:</p>
  <pre><code>foreach (string fileNameInFTP in directories)
                  {
                      //                string fileNameInFTP2 = Path.GetFileNameWithoutExtension(fileNameInFTP);
                      if ((!haveWeAlreadyParsedThisFile(fileNameInFTP)) &amp;&amp; (fileNameInFTP.Contains(&quot;CustsExport&quot;)) &amp;&amp; (!fileNameInFTP.EndsWith(&quot;Empty.xml&quot;)) &amp;&amp; (!fileNameInFTP.Contains(&quot;DelCustsExport&quot;)))
                      {
                          string file = FTPAddress + &quot;/&quot; + fileNameInFTP;
                          Console.WriteLine(file);
                          List&lt;Customer&gt; customersList =
                          (
                              from e in XDocument.Load(file).Root.Elements(&quot;cust&quot;)
                              select new Customer
                              {
                                  MemeberID = (int)e.Attribute(&quot;memberid&quot;),
                                  CustomerID = (int)e.Attribute(&quot;custid&quot;),
                                  FirstName = (string)e.Attribute(&quot;fname&quot;),
                                  LastName = (string)e.Attribute(&quot;lname&quot;),
                                  ShowsNumber = (int)e.Attribute(&quot;count_noshow&quot;),
                                  VisitNumber = (int)e.Attribute(&quot;count_resos&quot;),
                                  Cancellation = (int)e.Attribute(&quot;count_cancel&quot;),
                                  MobileNumber = (string)e.Element(&quot;phone&quot;).Attribute(&quot;phonenumber&quot;)
                                  /*Projects =
                                  (
                                      from p in e.Elements(&quot;projects&quot;).Elements(&quot;project&quot;)
                                      select new Project
                                      {
                                          ProjectCode = (string)p.Element(&quot;code&quot;),
                                          ProjectBudget = (int)p.Element(&quot;budget&quot;)
                                      }).ToArray()*/
                              }).ToList();
  </code></pre>
  <h3>Note:</h3> I am able to access the FTP because the `directories` variable is the list of the files in the FTP, and when I debug the code, I can see that it **has** the files, but the exception accurs in this line:
  <pre><code>                    List&lt;Customer&gt; customersList =
                      (
                          from e in XDocument.Load(file).Root.Elements(&quot;cust&quot;)
                          select new Customer
                          {
                              MemeberID = (int)e.Attribute(&quot;memberid&quot;),
                              CustomerID = (int)e.Attribute(&quot;custid&quot;),
                              FirstName = (string)e.Attribute(&quot;fname&quot;),
                              LastName = (string)e.Attribute(&quot;lname&quot;),
                              ShowsNumber = (int)e.Attribute(&quot;count_noshow&quot;),
                              VisitNumber = (int)e.Attribute(&quot;count_resos&quot;),
                              Cancellation = (int)e.Attribute(&quot;count_cancel&quot;),
                              MobileNumber = (string)e.Element(&quot;phone&quot;).Attribute(&quot;phonenumber&quot;)
                              /*Projects =
                              (
                                  from p in e.Elements(&quot;projects&quot;).Elements(&quot;project&quot;)
                                  select new Project
                                  {
                                      ProjectCode = (string)p.Element(&quot;code&quot;),
                                      ProjectBudget = (int)p.Element(&quot;budget&quot;)
                                  }).ToArray()*/
                          }).ToList();
  </code></pre>
  <p><strong>In other words: I am able to read the names of the files, but not the content of them.</strong></p>