943,714 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 906
  • C# RSS
You are currently viewing page 1 of this multi-page discussion thread
Jan 8th, 2009
0

Server Files in Combobox ??

Expand Post »
Hello fellow super coder people

i am rtying to list all the files in a certain directory (eg. "TestDir") in a combobox

C# Syntax (Toggle Plain Text)
  1. try
  2. {
  3. m_ftp.Server = txtftpServerName.Text;
  4. m_ftp.Username = txtftpUserName.Text;
  5. m_ftp.Password = txtftpPassword.Text;
  6.  
  7. m_ftp.Login();
  8. string[] The_File = m_ftp.GetFileList("TestDir");
  9.  
  10. foreach (string FILE in The_File)
  11. {
  12. cboFindFile.Items.Add(FILE);
  13. Console.Write(FILE);
  14. }
  15. m_ftp.Close();
  16. }
  17. catch(Exception EX)
  18. {
  19. MessageBox.Show("Files Not Downloaded");
  20. }

That only downloads one file into the combobox ...

Any ideas ???
please help...

Regards and thanks...
Last edited by cVz; Jan 8th, 2009 at 6:11 am.
Similar Threads
cVz
Reputation Points: 29
Solved Threads: 7
Junior Poster
cVz is offline Offline
139 posts
since Mar 2008
Jan 8th, 2009
1

Re: Server Files in Combobox ??

I would expect it to. youve asked it to show you the details of the directory, not the contents within it.
Reputation Points: 196
Solved Threads: 190
Posting Virtuoso
LizR is offline Offline
1,735 posts
since Aug 2008
Jan 8th, 2009
0

Re: Server Files in Combobox ??

Ok i understand that , thank you very much ... i tested a few other ways, but for argument sake lets say i said

C# Syntax (Toggle Plain Text)
  1. string[] The_Files = m_ftp.GetFileList("/");

or

C# Syntax (Toggle Plain Text)
  1. string[] The_Files = m_ftp.GetFileList("TestDir/");

or even

C# Syntax (Toggle Plain Text)
  1. string[] The_Files = m_ftp.GetFileList("//TestDir/");

/* Just keep in mind that the TCP is already connected so specifying just a directory works for Upload and delete */

It gives me the same problem , so could you maybe make my day worth wile and help me try something else ?

Even a total different approach is fine, i can adjust my code...

LizR - you rock , thanks for your help
cVz
Reputation Points: 29
Solved Threads: 7
Junior Poster
cVz is offline Offline
139 posts
since Mar 2008
Jan 8th, 2009
0

Re: Server Files in Combobox ??

try changing directory, and asking for a list of *
Reputation Points: 196
Solved Threads: 190
Posting Virtuoso
LizR is offline Offline
1,735 posts
since Aug 2008
Jan 8th, 2009
0

Re: Server Files in Combobox ??

NO luck yet ...

can you maybe give me some other example ??

Maybe a 'for' loop ??
cVz
Reputation Points: 29
Solved Threads: 7
Junior Poster
cVz is offline Offline
139 posts
since Mar 2008
Jan 8th, 2009
0

Re: Server Files in Combobox ??

debug it, is the array just 1 entry? if it is then.. thats why
Reputation Points: 196
Solved Threads: 190
Posting Virtuoso
LizR is offline Offline
1,735 posts
since Aug 2008
Jan 8th, 2009
0

Re: Server Files in Combobox ??

The directory contains about 5 zipped files , trust me i have been debugging ... hahaha, i guess this leaves me at phase one again, but rest asured, i never give up, i will post the working code soon, watch this space ... hehehe

The problem must be within the loop somewhere, thats why i think maybe doing a 'for' loop rather than a 'foreach' loop, because it does give me the first file in the dir, but there are about five .bak files that are zipped ... so lets say .zip files

Anyway , thanks for your attempt
cVz
Reputation Points: 29
Solved Threads: 7
Junior Poster
cVz is offline Offline
139 posts
since Mar 2008
Jan 8th, 2009
0

Re: Server Files in Combobox ??

no no, you're missing the point.
If the function you're calling only sends back the 1 file, then thats all it has to send. For loop and foreach wont make any difference.

if the array only has the 1 file, you cant change that
Last edited by LizR; Jan 8th, 2009 at 9:10 am.
Reputation Points: 196
Solved Threads: 190
Posting Virtuoso
LizR is offline Offline
1,735 posts
since Aug 2008
Jan 8th, 2009
0

Re: Server Files in Combobox ??

Ok i think i know whats wrong here

i think that the files are not registering in the array - what you said

C# Syntax (Toggle Plain Text)
  1. private void FindFiles(object sender, EventArgs e)
  2. {
  3. try
  4. {
  5. m_ftp.Server = txtftpServerName.Text;
  6. m_ftp.Username = txtftpUserName.Text;
  7. m_ftp.Password = txtftpPassword.Text;
  8.  
  9. m_ftp.Login();
  10.  
  11. m_ftp.ChangeDir(txtToDirectory.Text);
  12.  
  13. string[] fi = m_ftp.GetFileList();
  14.  
  15. cboFindFile.Items.AddRange(fi);
  16.  
  17. m_ftp.Close();
  18. }
  19. catch(Exception EX)
  20. {
  21. MessageBox.Show("File Not Downloaded");
  22. }
  23. }

I dont even have a loop there but it works exactly the same ...
Last edited by cVz; Jan 8th, 2009 at 9:30 am.
cVz
Reputation Points: 29
Solved Threads: 7
Junior Poster
cVz is offline Offline
139 posts
since Mar 2008
Jan 8th, 2009
0

Re: Server Files in Combobox ??

So GetFileList isnt returning more than 1 thing.
Reputation Points: 196
Solved Threads: 190
Posting Virtuoso
LizR is offline Offline
1,735 posts
since Aug 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: add custom control to outlook toolbar in VSTO
Next Thread in C# Forum Timeline: Null reference in array





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC