• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 530
  • Last Modified:

Remove special character from string

using C# I have a string which is a filename of a file being uploaded. on some systems a period can be used as part of a filename like ".testfile.pdf"  I need to remove the period only if it is the first character in the string.  I have tried replace but all periods are removed and i haven't been able to tuse regex either.
0
rmardis
Asked:
rmardis
1 Solution
 
lenordisteCommented:
you can use TrimStart from string to do that: http://msdn.microsoft.com/fr-fr/library/system.string.trimstart.aspx

for example:
  string cleanFileName = ".testfile.txt".TrimStart('.');
0
 
rmardisAuthor Commented:
This was it, Thank you for your speedy answer.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now