Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / December 2007

Tip: Looking for answers? Try searching our database.

Generate Verbatim Text in C#

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
CapCity - 18 Dec 2007 20:04 GMT
We have an application that needs to read in a text file (SAS Source Code)
as a string, does text substitution with it, and runs a SAS process with
this string as a parameter. The problem is that the SAS source code has some
double quotes in it, and some of the substitutions are full file paths, with
the slashes.

So what we're feeding into the SAS processor is \"text\" instead of "text"
and C:\\Folder\\File.txt instead of C:\Folder\File.

Is there a way to get the string values to work as the verbatim literals do?
Without the escape characters? If there is, then I'm not using the correct
keywords to search on, because I can't find it.

Thanks in advance.
Peter Duniho - 18 Dec 2007 20:30 GMT
> We have an application that needs to read in a text file (SAS Source  
> Code)
[quoted text clipped - 8 lines]
> "text"
> and C:\\Folder\\File.txt instead of C:\Folder\File.

Sounds to me as though you're making the classic error of thinking that  
the string the debugger shows you is character-for-character what's  
actually in the string.

The debugger shows you a string that has stuff like that escaped.  But the  
string itself doesn't actually literally contain a backslash followed by a  
quote or another backslash or whatever.  It just has the escaped character  
itself (the quote, backslash, etc.)

In other words, you don't need to do anything special to get the verbatim  
text.  Read the text into a string from a file, and the string will have  
precisely the same text in it that the file has (or as near as is  
possible, given any encoding conversion that might have  
happened...normally there wouldn't be any limitations here though).

Pete
CapCity - 19 Dec 2007 13:14 GMT
>> We have an application that needs to read in a text file (SAS Source
>> Code)
[quoted text clipped - 25 lines]
>
> Pete

Pete,

You're exactly right - thanks for straightening me out.

And thanks for calling it a "classic" error. Made me feel a little better
about my brain-lapse.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.