473,401 Members | 2,068 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,401 software developers and data experts.

Escape chracter error?

I have an illegal character error so i used @ escape character but it
doesnt work how can i make this work possible

String dir =
myproc[i].MainModule.FileName.ToString();
FileVersionInfo info =
FileVersionInfo.GetVersionInfo(@dir);

Thanks
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Nov 16 '05 #1
8 1359
Hi,

Can you post a sample application that exibits this behavoir? From your
code I cannot tell what is being populated in the dir variable so I am unable
to diagnose properly. Please reply to this post so the group may help you
better.

Thanks.
Nov 16 '05 #2
AFAIK @ for strings only applies to string literals:
string stringOne = "Hello\tWorld";
string stringTwo = @"Hello\tWorld";

if(@stringOne == stringTwo) {
// This will never execute, since stringOne has a tab character where
stringTwo has a literal "\t" in it.
}

The other main use of @ is to allow you to use keywords as names in your
application:
int public = 0; // Compile error
int @public = 0; // No compile error

"Dakkar" <da****@sylveria.gen-dot-tr.no-spam.invalid> wrote in message
news:42********@127.0.0.1...
I have an illegal character error so i used @ escape character but it
doesnt work how can i make this work possible

String dir =
myproc[i].MainModule.FileName.ToString();
FileVersionInfo info =
FileVersionInfo.GetVersionInfo(@dir);

Thanks
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com

Nov 16 '05 #3
"Sean Hederman" <us***@blogentry.com> wrote in news:cuta49$iq0$1@ctb-
nnrp2.saix.net:
AFAIK @ for strings only applies to string literals:


Correct.
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Get your ASP.NET in gear with IntraWeb!
http://www.atozed.com/IntraWeb/
Nov 16 '05 #4
Dakkar <da****@sylveria.gen-dot-tr.no-spam.invalid> wrote:
I have an illegal character error so i used @ escape character but it
doesnt work how can i make this work possible

String dir =
myproc[i].MainModule.FileName.ToString();
FileVersionInfo info =
FileVersionInfo.GetVersionInfo(@dir);


I don't think you understand what "@" is for. It's to either specify
that the following token is an identifier even if it's a keyword (so
you could use "if" as a variable by writing @if everywhere, for
example) or to specify that a string literal should be treated
verbatim. It doesn't change the value of a string variable or anything
like that.

See http://www.pobox.com/~skeet/csharp/strings.html for more
information.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #5
So what should i do ?
my string is a process path like C:\Program Files\etc
how can i prevent this illegal character error
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Nov 16 '05 #6
Dakkar <da****@sylveria.gen-dot-tr.no-spam.invalid> wrote:
So what should i do ?
my string is a process path like C:\Program Files\etc
how can i prevent this illegal character error


Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #7
Hi Dakkar,

Thanks for posting your code. It always helps in diagnosis. I think that
you would benefit from creating a simple program and outputting your results
on the command line. Take a look at Jon's post earlier for a link on how to
do this. In the meantime...

In the statement:

String dir = @myproc[i].MainModule.FileName.ToString();

remove the @ symbol. There is no point in it here. Then add a breakpoint
in your code at this point and examine the value of dir. If this looks
acceptable (e.g. a real path name and file then move on to the
FileVersionInfo myinfo variable. Once this variable has been assigned a
value examine the contents to ensure that you haven't encountered an error.
My bet is that you cannot get properties for the file for some reason or the
file name is not a good one. You probably should wrap this whole bit of code
in a try...catch block to ensure that everything is getting executed
properly.

On a side note...It has been my experience that when you attempt to get a
value that was assigned to the FileVersionInfo there is a high possibility
that an exception can be thrown (i.e. if something else is holding on to the
file and it cannot access it, etc...) so you want to handle these and react
appropriately.

Nov 16 '05 #8
Dakkar <da****@sylveria.gen-dot-tr.no-spam.invalid> wrote:
Here is my complete program
public bool proccescheck()


<snip>

Complete programs don't start by declaring methods. They will always
include a type declaration before a method declaration.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #9

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

Similar topics

3
by: Paul | last post by:
I have an Access 2000 database with a form that is giving me some major headaches. When you open the form, it displays all records and allows editing, but has AllowAdditions set to False so that...
5
by: deko | last post by:
Is there a way to programmatically emulate pressing the Escape key with VBA? (Access 2003) What I'm trying to do is clear a field in a form (which otherwise requires the user to press Escape)...
7
by: teachtiro | last post by:
Hi, 'C' says \ is the escape character to be used when characters are to be interpreted in an uncommon sense, e.g. \t usage in printf(), but for printing % through printf(), i have read that %%...
18
by: Steve Litvack | last post by:
Hello, I have built an XMLDocument object instance and I get the following string when I examine the InnerXml property: <?xml version=\"1.0\"?><ROOT><UserData UserID=\"2282\"><Tag1...
5
by: Steven C | last post by:
Hello! I am trying to connect to a SQL Server (MSDE) database in mixed mode authentication, via C#, but when I use the MSDE instance name, I keep getting an "Unrecognized Escape Sequence"...
12
by: Jeff S | last post by:
In a VB.NET code behind module, I build a string for a link that points to a JavaScript function. The two lines of code below show what is relevant. PopupLink = "javascript:PopUpWindow(" &...
15
by: pkaeowic | last post by:
I am having a problem with the "escape" character \e. This code is in my Windows form KeyPress event. The compiler gives me "unrecognized escape sequence" even though this is documented in MSDN....
0
by: Asif Mohammed | last post by:
Hello, I have a datagridview bound to a database table with 2 columns. One is an ID column "NameID" which is hidden, the other is called "Name". The schema picture is here :...
17
by: newcoder10 | last post by:
Hi All, I would like to know what's the best way to write function(global) in asp.net c# Framework 2.0 to check for textbox in a form (i have about 80 textbox on one form and I have many forms and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.