After a lot of testing etc, i decided to move away from the 3rd party FTP classes and use the standard Microsoft FtpWebRequest for faster speeds etc...

What i want to do is list the directories in a treeview!

Now here's my code :

try
            {
                FTPRequest = (FtpWebRequest)WebRequest.Create("ftp://iwantstringsman");
                FTPRequest.Method = WebRequestMethods.Ftp.ListDirectoryDetails;

                FTPRequest.Credentials = new NetworkCredential(txtftpUserName.Text, txtftpPassword.Text);

                FtpWebResponse FTPResponse = (FtpWebResponse)FTPRequest.GetResponse();

                Stream FTPResponseStream = FTPResponse.GetResponseStream();
                StreamReader reader = new StreamReader(FTPResponseStream);
                Console.WriteLine(reader.ReadToEnd());



                Console.WriteLine("Directory List Complete, status {0}");

                foreach (char S in reader.ReadToEnd())
                {
                    /*          Making parent node          */
                    TreeNode ParentNode = new TreeNode();
                    ParentNode.Text = S.ToString(); ;

                    treeView1.Nodes.Add(ParentNode);
                }

                reader.Close();
                FTPResponseStream.Close();
            }
            catch (Exception EX)
            {
                MessageBox.Show(EX.Message);
            }

Problem is this (the reader.ReadToEnd() only supports Characters)

how can i get this in string format ???

Regards...

Thanks in advance

Hello, cVz.
StreamReader.ReadToEnd method has this signature (taken from MSDN):

public override string ReadToEnd()

The returning type is string.
Am I misunderstood something?

I know , but it doesn't , its made up of char's, sadly enough ....

i just want to know how to convert this back to string...

But strings *ARE* made of chars..
the fact you're walking through them (at your request) as chars, will mean you get chars back..

FTPRequest.Method = WebRequestMethods.Ftp.ListDirectoryDetails;

there are the details

But im just in beta mode for now , never worked with MS FtpWebRequest before ...

but hey man , like i always say , give me a day and i'll be posting full code snippets on here..

Ps read your messages :P

I dont read and answer personal messages, unless Ive asked for them.

But as Antenka said, its a string, the string consists of a number of lines.. all worked fine for me as long as I turned passive ftp off (possibly due to where I am) using reader.ReadtoEnd()

Maybe your troubles caused by way, you use to read from stream?

foreach (char S in reader.ReadToEnd())

foreach (char S in reader.ReadToEnd())

?????????????????????????????????????????????????

then i get little characters... hmmm...ok something doesnt click here ...

error CS0030: Cannot convert type 'char' to 'string'

i cant understand why its not reading it because ive even tried converting it ...

Antenka, you were right , readToEnd() is string format , but its not an array ... ahaaaaaa, so how can we make an array here is the new question...

Well, thats been covered enough times on this forum for you to be able to find it. But of course you will ignore me as you have all throughout this thread.

Antenka, you were right , readToEnd() is string format , but its not an array

Didn't said, that this is array. That part of code was taken from your's first post ...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.