RSS Forums RSS

Server Files in Combobox ??

Please support our C# advertiser: DiscountASP.NET – 3 Months Free on C# Web Hosting
Reply
Posts: 117
Reputation: cVz is an unknown quantity at this point 
Solved Threads: 6
cVz's Avatar
cVz cVz is offline Offline
Junior Poster

Server Files in Combobox ??

  #1  
Jan 8th, 2009
Hello fellow super coder people

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

try
            {
                m_ftp.Server = txtftpServerName.Text;
                m_ftp.Username = txtftpUserName.Text;
                m_ftp.Password = txtftpPassword.Text;

                m_ftp.Login();
                string[] The_File = m_ftp.GetFileList("TestDir");

                foreach (string FILE in The_File)
                {
                    cboFindFile.Items.Add(FILE);
                    Console.Write(FILE);
                }
                m_ftp.Close();
            }
            catch(Exception EX)
            {
                MessageBox.Show("Files Not Downloaded");
            }

That only downloads one file into the combobox ...

Any ideas ???
please help...

Regards and thanks...
Last edited by cVz : Jan 8th, 2009 at 5:11 am.
Delphi & C# programmer deluxe...
AddThis Social Bookmark Button
Reply With Quote  
Posts: 1,734
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 184
LizR LizR is offline Offline
Posting Virtuoso

Re: Server Files in Combobox ??

  #2  
Jan 8th, 2009
I would expect it to. youve asked it to show you the details of the directory, not the contents within it.
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote  
Posts: 117
Reputation: cVz is an unknown quantity at this point 
Solved Threads: 6
cVz's Avatar
cVz cVz is offline Offline
Junior Poster

Re: Server Files in Combobox ??

  #3  
Jan 8th, 2009
Ok i understand that , thank you very much ... i tested a few other ways, but for argument sake lets say i said

string[] The_Files = m_ftp.GetFileList("/");

or

string[] The_Files = m_ftp.GetFileList("TestDir/");

or even

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
Delphi & C# programmer deluxe...
Reply With Quote  
Posts: 1,734
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 184
LizR LizR is offline Offline
Posting Virtuoso

Re: Server Files in Combobox ??

  #4  
Jan 8th, 2009
try changing directory, and asking for a list of *
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote  
Posts: 117
Reputation: cVz is an unknown quantity at this point 
Solved Threads: 6
cVz's Avatar
cVz cVz is offline Offline
Junior Poster

Re: Server Files in Combobox ??

  #5  
Jan 8th, 2009
NO luck yet ...

can you maybe give me some other example ??

Maybe a 'for' loop ??
Delphi & C# programmer deluxe...
Reply With Quote  
Posts: 1,734
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 184
LizR LizR is offline Offline
Posting Virtuoso

Re: Server Files in Combobox ??

  #6  
Jan 8th, 2009
debug it, is the array just 1 entry? if it is then.. thats why
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote  
Posts: 117
Reputation: cVz is an unknown quantity at this point 
Solved Threads: 6
cVz's Avatar
cVz cVz is offline Offline
Junior Poster

Re: Server Files in Combobox ??

  #7  
Jan 8th, 2009
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
Delphi & C# programmer deluxe...
Reply With Quote  
Posts: 1,734
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 184
LizR LizR is offline Offline
Posting Virtuoso

Re: Server Files in Combobox ??

  #8  
Jan 8th, 2009
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 8:10 am.
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote  
Posts: 117
Reputation: cVz is an unknown quantity at this point 
Solved Threads: 6
cVz's Avatar
cVz cVz is offline Offline
Junior Poster

Re: Server Files in Combobox ??

  #9  
Jan 8th, 2009
Ok i think i know whats wrong here

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

private void FindFiles(object sender, EventArgs e)
        {
            try
            {
                m_ftp.Server = txtftpServerName.Text;
                m_ftp.Username = txtftpUserName.Text;
                m_ftp.Password = txtftpPassword.Text;

                m_ftp.Login();

                m_ftp.ChangeDir(txtToDirectory.Text);

                string[] fi = m_ftp.GetFileList();

                cboFindFile.Items.AddRange(fi);

                m_ftp.Close();
            }
            catch(Exception EX)
            {
                MessageBox.Show("File Not Downloaded");
            }
        }

I dont even have a loop there but it works exactly the same ...
Last edited by cVz : Jan 8th, 2009 at 8:30 am.
Delphi & C# programmer deluxe...
Reply With Quote  
Posts: 1,734
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 184
LizR LizR is offline Offline
Posting Virtuoso

Re: Server Files in Combobox ??

  #10  
Jan 8th, 2009
So GetFileList isnt returning more than 1 thing.
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.



Similar Threads
Other Threads in the C# Forum
Views: 498 | Replies: 12 | Currently Viewing: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 3:28 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC