473,394 Members | 1,765 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

problem with string conversion CSharp

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


Dec 4 '06 #1
3 1075
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

Ihi,
II have a fileName stored as a string as shown:
IString fn = @"C:\drawing\testdrawings\test;
Iwhich gives fn = "C:\\drawing\\testdrawings\\test; however i dont
Iwant '\' to get converted to '\\'
I>
IThe reason i need to remove one of the '\' is because, i have a
IdataTable
Iwhere I search for the files using
Ifn as a searach criteria. Since the two strings arent equal
Itherfore it
Idoesnt retireve any data.
ICan someone help me with this problem.
I>
ITIA
IIrfan
---
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 Nietzsche
Dec 4 '06 #2
Irfan <ir***@asc-ltd.co.ukwrote:
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 '\\'
See http://www.pobox.com/~skeet/csharp/s....html#debugger

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Dec 4 '06 #3
thanks for your replies
irfan
"Jon Skeet [C# MVP]" <sk***@pobox.comwrote in message
news:MP************************@msnews.microsoft.c om...
Irfan <ir***@asc-ltd.co.ukwrote:
>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 '\\'

See http://www.pobox.com/~skeet/csharp/s....html#debugger

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Dec 5 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Sunny | last post by:
Hi all, I have found a possible bug in the Uri class constructor. When I make something like this: test = new Uri(@"http://www.test.com/dir1/page1.html"); test2 = new Uri(test,...
4
by: james | last post by:
I upgraded my 2002 project to 2003 and I am getting several of there errors on my forms xxxForm.resx Resource transformation for file 'xxxForm.resx' failed. Possible Version mismatch. Type...
5
by: Lucas | last post by:
Well, here's the situation.. It's pretty simple; just that I can't get it to work. I have 2 Executables.. The first one is called CSharp.exe which is a simple WinForm App. I have a single...
11
by: Steve Gough | last post by:
Could anyone please help me to understand what is happening here? The commented line produces an error, which is what I expected given that there is no conversion defined from type double to type...
2
by: Kimmo Laine | last post by:
Hi, any ideas: how can i convert "0x12" to int in C#? Kimmo Laine
6
by: KA Kueh | last post by:
Dear all, I have a requirement to replace the ' character with ASCII character (146) in C# but it seems that when I do the following the conversion is lost. char t = Convert.ToChar(146);...
5
by: Lasse Edsvik | last post by:
Hello I have this: public SqlParameter GetParameter(string sqlparam) { SqlParameter param = cmd.Parameters.Add(sqlparam);
7
by: rbeyea | last post by:
I am writing a DLL (DLL1) that is wrapping another DLL (DLL2). I need to extract the information returned from DLL2 and pass it out to the Client application this is using DLL1. DLL2 returns...
16
by: Dany | last post by:
Our web service was working fine until we installed .net Framework 1.1 service pack 1. Uninstalling SP1 is not an option because our largest customer says service packs marked as "critical" by...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.