Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

String.Replace 2

Status
Not open for further replies.

esdee

Programmer
Apr 12, 2001
143
US
i have an OpenFileDialog dlg and i
get a selected filename with
string s1 = dlg.FileNames[0];
then i need to replace \ with /
s1.Replace('\\', '/');

but it doesn't work !

how should i code this ?

thanx
 
cappmgr is right but I want to give you a solution to deal with the directory char separator:
s1 = s1.Replace(System.IO.Path.DirectorySeparatorChar,System.IO.Path.AltDirectorySeparatorChar);

-obislavu-
 
thank you, guys
somehow
str1 = str2.replace() doesn't work
while str2 = str2.replace() works

strange

i dont need the functionality of
System.IO.Path.DirectorySeparatorChar
for now, but thanx for the tip anyway
 
esdee -
You might want to rethink your decision not to use the system constants for this.

Unless this is throwaway code?

Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
it just suits my current needs - i have to pass a string to mysql and it whats the path to be with '/'s instead of '\'s
 
OK, don't say we didn't warn you.

Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top