2 String Questions

  • Thread starter Thread starter shapper
  • Start date Start date
S

shapper

Hello,

I am having 2 problems related with strings:

1. I have a string as follows: "File01.xml,File02.xml,File03.xml"
I need to create an array where first item is "File01.xml", second
item is "File02.xml", etc.

2. When having string "File01.xml" I need to get "File01" by removing
".xml"

Could someone help me out with this?

Thanks,
Miguel
 
Hi Miguel,

First, I'll answer your questions, then point you to some resources to help
you in the future.
1. I have a string as follows: "File01.xml,File02.xml,File03.xml"
I need to create an array where first item is "File01.xml", second
item is "File02.xml", etc.

string s = "File01.xml,File02.xml,File03.xml";
string[] fileNames = s.Split(',');

http://msdn2.microsoft.com/en-us/library/system.string.aspx
2. When having string "File01.xml" I need to get "File01" by removing
".xml"

String s = "File01.xml";
String trimmed = System.IO.Path.GetFileNameWithoutExtension(s);

http://msdn2.microsoft.com/en-us/library/system.io.path.aspx

--
HTH,

Kevin Spencer
Microsoft MVP
Ministry of Software Development
http://unclechutney.blogspot.com

I just flew in from Chicago with
a man with a wooden leg named Smith
who shot an elephant in my pajamas.
So I bit him.
 
Back
Top