title: Ftp FolderView File Browse in Asp.net C#
body: <p>In my Web Application I need to give facility to the user to browse their FTP Location, as of File Browse of Asp.Net.</p>
  
  <p>To do so, I have used <code>OpenFileDialog</code> of Windows Forms. It works for any local location, but it does not work for any ftp location. </p>
  
  <p>Below is my Code. </p>
  
  <pre><code>    protected void BtnOpenFileDialog_Click(object sender, EventArgs e)
      {
          var t = new Thread(SelectFolder);
          t.IsBackground = true;
          t.SetApartmentState(ApartmentState.STA);
          t.Start();
      }
  
      private void SelectFolder()
      {
          Stream myStream = null;
          OpenFileDialog openFileDialog1 = new OpenFileDialog();
  
          openFileDialog1.InitialDirectory = "ftp://username:password@ftpidaddress/";
          openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
          openFileDialog1.FilterIndex = 2;
          openFileDialog1.RestoreDirectory = false;
  
          if (openFileDialog1.ShowDialog() == DialogResult.OK)
          {
              try
              {
                  if ((myStream = openFileDialog1.OpenFile()) != null)
                  {
                      using (myStream)
                      {
                          // code to read the stream here.
                      }
                  }
              }
              catch (Exception ex)
              {
                  // exception handing here
              }
          }
      }
  </code></pre>
  
  <p>Please suggest me if I am doing anything wrong in it.. 
  Or suggest me if any other ways to do so.</p>