Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i am using to store the path in db as "images/09303 .jpg" i need to remove those spaces !! HOW ?

thanks in advance
Posted

Do you really need to remove the spaces? If this is the relative physical path to a file and you remove the spaces, you won't be able to read the file again later on if you need to display it.

If you must remove the spaces, the place to do this is really in your calling code - I'll assume that you have a business rule that you need to implement here which is why you want to remove the spaces; if so, that should be enforced as business logic.
 
Share this answer
 
Do it like this:

filename = filename.Replace(" ", "");


...but if the filename on the disk actually includes the spaces in the name, you won't be able to find it later when you retrieve the name from the DB...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900