problem with string conversion CSharp

  • Thread starter Thread starter Irfan
  • Start date Start date
I

Irfan

hi,
I have a fileName stored as a string as shown:
String fn = @"C:\drawing\testdrawings\test;

which gives fn = "C:\\drawing\\testdrawings\\test;
however i dont want '\' to get converted to '\\'


The reason i need to remove one of the '\' is because, i have a dataTable
where I search for the files using
fn as a searach criteria. Since the two strings arent equal therfore it
doesnt retireve any data.

Can someone help me with this problem.

TIA
Irfan
 
Hello Irfan,

The "\" is the symbol for the escape sequence. If you can't have the single
"\" in your string.
Thing about the other way of comparing your strings, like comparing arrays
or smth else.
BTW, you can use Path.GetDirectoryName methods to get the stucture of you
path with the DirectorySeparatorChar symbol
which can help you compare your data

I> hi,
I> I have a fileName stored as a string as shown:
I> String fn = @"C:\drawing\testdrawings\test;
I> which gives fn = "C:\\drawing\\testdrawings\\test; however i dont
I> want '\' to get converted to '\\'
I>
I> The reason i need to remove one of the '\' is because, i have a
I> dataTable
I> where I search for the files using
I> fn as a searach criteria. Since the two strings arent equal
I> therfore it
I> doesnt retireve any data.
I> Can someone help me with this problem.
I>
I> TIA
I> Irfan
---
WBR,
Michael Nemtsev [C# MVP] :: blog: http://spaces.live.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsch
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top