Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Putting Array data in a string then showing it in a label.

Putting Array data in a string then showing it in a label.

Scheduled Pinned Locked Moved C#
data-structureshelpquestion
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    eggie5
    wrote on last edited by
    #1

    I have an array...

    	private void Page\_Load(object sender, System.EventArgs e)
    	{
    		string \[\] dirs = Directory.GetDirectories(@"c:\\inetpub\\wwwroot\\shares\\folder\\", "b\*");
    		labelPath.Text=dirs.ToString();
    	}
    

    as you can see it's value is assigned to the string "dirs" now I want it to show up thought he label "labelPath", but when I compile the page it shows "System.String[]".... I need it to show the names of folders that start with "b", I can make it work as a consle application, but not a aspx page... can somebody please help...??? /\ |_ E X E GG

    L 1 Reply Last reply
    0
    • E eggie5

      I have an array...

      	private void Page\_Load(object sender, System.EventArgs e)
      	{
      		string \[\] dirs = Directory.GetDirectories(@"c:\\inetpub\\wwwroot\\shares\\folder\\", "b\*");
      		labelPath.Text=dirs.ToString();
      	}
      

      as you can see it's value is assigned to the string "dirs" now I want it to show up thought he label "labelPath", but when I compile the page it shows "System.String[]".... I need it to show the names of folders that start with "b", I can make it work as a consle application, but not a aspx page... can somebody please help...??? /\ |_ E X E GG

      L Offline
      L Offline
      leppie
      wrote on last edited by
      #2

      Look at String.Join() leppie::AllocCPArticle(Generic DFA State Machine for .NET);

      E 1 Reply Last reply
      0
      • L leppie

        Look at String.Join() leppie::AllocCPArticle(Generic DFA State Machine for .NET);

        E Offline
        E Offline
        eggie5
        wrote on last edited by
        #3

        string [] dirs = Directory.GetDirectories(@"c:\inetpub\wwwroot\shares\folder\", "b*");

        I tried the Join Method but I can't get it to turn the above array "dirs" into a regular string that I can show though a label.... :-Ocan you show me? /\ |_ E X E GG

        L 1 Reply Last reply
        0
        • E eggie5

          string [] dirs = Directory.GetDirectories(@"c:\inetpub\wwwroot\shares\folder\", "b*");

          I tried the Join Method but I can't get it to turn the above array "dirs" into a regular string that I can show though a label.... :-Ocan you show me? /\ |_ E X E GG

          L Offline
          L Offline
          leppie
          wrote on last edited by
          #4

          Try delimiting the strings with "<BR>". leppie::AllocCPArticle(Generic DFA State Machine for .NET);

          E 1 Reply Last reply
          0
          • L leppie

            Try delimiting the strings with "<BR>". leppie::AllocCPArticle(Generic DFA State Machine for .NET);

            E Offline
            E Offline
            eggie5
            wrote on last edited by
            #5

            huh? /\ |_ E X E GG

            D 1 Reply Last reply
            0
            • E eggie5

              huh? /\ |_ E X E GG

              D Offline
              D Offline
              Daniel Turini
              wrote on last edited by
              #6

              try

              Console.WriteLine(String.Join('\n', dirs));

              ORACLE One Real A$#h%le Called Lary Ellison

              L 1 Reply Last reply
              0
              • D Daniel Turini

                try

                Console.WriteLine(String.Join('\n', dirs));

                ORACLE One Real A$#h%le Called Lary Ellison

                L Offline
                L Offline
                Leon van Wyk
                wrote on last edited by
                #7

                foreach(string x in Dirs) { labelPath.Text = labelPath.Text + x + "\n"; } \\the "\n" is for newline! if you want a new line! Leon v Wyk

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups