How can I split text? ... treenodes  
Author Message
Michael_P2234





PostPosted: Visual C# General, How can I split text? ... treenodes Top

I'm working on a program that returns a registry key's path. The path always return in the format "Root_Key\Subkey\Subkey\key". I also have a list that stores the subkeys found and I need a way that I can read from its path and add each path individually to a treeview's list so it will be like regular RegEdit, but it only shows what you have searched for.


Visual C#5  
 
 
Peter Ritchie





PostPosted: Visual C# General, How can I split text? ... treenodes Top



 
 
Michael_P2234





PostPosted: Visual C# General, How can I split text? ... treenodes Top

This returns errors.

Error 1 Cannot implicitly convert type 'char[]' to 'char' H:\C#\stringSplit\stringSplit\Form1.cs 24 60 stringSplit

Error 3 Newline in constant H:\C#\stringSplit\stringSplit\Form1.cs 24 60 stringSplit
Error 4 Too many characters in character literal H:\C#\stringSplit\stringSplit\Form1.cs 24 60 stringSplit
Error 5 } expected H:\C#\stringSplit\stringSplit\Form1.cs 27 2 stringSplit
Error 6 Invalid expression term '' H:\C#\stringSplit\stringSplit\Form1.cs 24 59 stringSplit
Error 7 } expected H:\C#\stringSplit\stringSplit\Form1.cs 24 60 stringSplit
Error 8 ; expected H:\C#\stringSplit\stringSplit\Form1.cs 24 66 stringSplit
Error 9 { expected H:\C#\stringSplit\stringSplit\Form1.cs 24 66 stringSplit

 
]

 

 



 
 
Peter Ritchie





PostPosted: Visual C# General, How can I split text? ... treenodes Top

Sorry, it was air code, try:

string .Split(new char[] {'\\'});



 
 
Mousy





PostPosted: Visual C# General, How can I split text? ... treenodes Top

string txtpath="abc/def/ghi"

string[] strArray=txtpath.Split('/');

the string strArray will contain all the splitted text

txtpath[0]-->abc

txtpath[1]-->def

txtpath[2]-->ghi


 
 
David L





PostPosted: Visual C# General, How can I split text? ... treenodes Top

string

Did that solve it


 
 
Michael_P2234





PostPosted: Visual C# General, How can I split text? ... treenodes Top

Yep, and you have to use single quotes I guess.