473,769 Members | 4,601 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

strange c# - vb difference

I'm using 1.1/vs.net 2003 ...

C#example...... ........

string myPath = Server.MapPath( ".\\Data\\" + (string)
Session["LogoFileNa me"]);

Produces this value in myPath

?myPath
@"c:\inetpub\ww wroot\CSharpCus tomers\Data\Gar yRocks.jpg"

VB example........ .....

Dim myPath As String = Server.MapPath( ".\Data\" + Session("LogoFi leName"))

?myPath
"C:\Inetpub\www root\CPCustomer s\Data\GaryRock s.jpg"

the vb example works. the c# does not work. I notice that @ preceding the
string in the c# example. Could that be the difference? What am I doing
wrong in the C# example?

thanks,
T
Jun 1 '06 #1
7 1427

"Tina" <ti**********@n ospammeexcite.c om> wrote in message
news:ej******** ********@TK2MSF TNGP02.phx.gbl. ..
I'm using 1.1/vs.net 2003 ...

C#example...... ........

string myPath = Server.MapPath( ".\\Data\\" + (string)
Session["LogoFileNa me"]);

Produces this value in myPath

?myPath
@"c:\inetpub\ww wroot\CSharpCus tomers\Data\Gar yRocks.jpg"

VB example........ .....

Dim myPath As String = Server.MapPath( ".\Data\" + Session("LogoFi leName"))

?myPath
"C:\Inetpub\www root\CPCustomer s\Data\GaryRock s.jpg"

the vb example works. the c# does not work. I notice that @ preceding
the string in the c# example. Could that be the difference? What am I
doing wrong in the C# example?


The only difference I see here is CSharpCustomers vs. CPCustomers, which I
hope is a typing error on your part, or else it makes no sense at all.

In C#, the @ means that backslashes in the string are not to be given
special interpretation.

So @"\" and "\\" in C# are both the same as "\" in Basic.
Jun 1 '06 #2
The backward slash (\) character can be used in a format string to turn off
the special meaning of
the character that follows it. For example, "\{" will cause a literal "{" to
be displayed, and "\\" will
display a literal "\". The at sign (@) character can be used to represent an
entire string verbatim. For
example, @"\\server\shar e" will be processed as \\server\share.

chanmm
"Tina" <ti**********@n ospammeexcite.c om> wrote in message
news:ej******** ********@TK2MSF TNGP02.phx.gbl. ..
I'm using 1.1/vs.net 2003 ...

C#example...... ........

string myPath = Server.MapPath( ".\\Data\\" + (string)
Session["LogoFileNa me"]);

Produces this value in myPath

?myPath
@"c:\inetpub\ww wroot\CSharpCus tomers\Data\Gar yRocks.jpg"

VB example........ .....

Dim myPath As String = Server.MapPath( ".\Data\" + Session("LogoFi leName"))

?myPath
"C:\Inetpub\www root\CPCustomer s\Data\GaryRock s.jpg"

the vb example works. the c# does not work. I notice that @ preceding
the string in the c# example. Could that be the difference? What am I
doing wrong in the C# example?

thanks,
T

Jun 1 '06 #3
Yes, I know that. That's why I put the extra back slashes in the c#
version. Have you any idea why the C# version canot find the jpg?
T

"chanmm" <ch*****@hotmai l.com> wrote in message
news:%2******** ********@TK2MSF TNGP03.phx.gbl. ..
The backward slash (\) character can be used in a format string to turn
off the special meaning of
the character that follows it. For example, "\{" will cause a literal "{"
to be displayed, and "\\" will
display a literal "\". The at sign (@) character can be used to represent
an entire string verbatim. For
example, @"\\server\shar e" will be processed as \\server\share.

chanmm
"Tina" <ti**********@n ospammeexcite.c om> wrote in message
news:ej******** ********@TK2MSF TNGP02.phx.gbl. ..
I'm using 1.1/vs.net 2003 ...

C#example...... ........

string myPath = Server.MapPath( ".\\Data\\" + (string)
Session["LogoFileNa me"]);

Produces this value in myPath

?myPath
@"c:\inetpub\ww wroot\CSharpCus tomers\Data\Gar yRocks.jpg"

VB example........ .....

Dim myPath As String = Server.MapPath( ".\Data\" +
Session("LogoFi leName"))

?myPath
"C:\Inetpub\www root\CPCustomer s\Data\GaryRock s.jpg"

the vb example works. the c# does not work. I notice that @ preceding
the string in the c# example. Could that be the difference? What am I
doing wrong in the C# example?

thanks,
T


Jun 1 '06 #4
I'm coverting a vb project to a c# project so those are the names of the two
projects.

Thanks for telling me what the @ means. Your explanation tells me the two
strings are identical (albiet the diff in project names). My mystery
remains as to why the c# version cannot find the jpg.
T
"Michael A. Covington" <lo**@ai.uga.ed u.for.address> wrote in message
news:e5******** ******@TK2MSFTN GP05.phx.gbl...

"Tina" <ti**********@n ospammeexcite.c om> wrote in message
news:ej******** ********@TK2MSF TNGP02.phx.gbl. ..
I'm using 1.1/vs.net 2003 ...

C#example...... ........

string myPath = Server.MapPath( ".\\Data\\" + (string)
Session["LogoFileNa me"]);

Produces this value in myPath

?myPath
@"c:\inetpub\ww wroot\CSharpCus tomers\Data\Gar yRocks.jpg"

VB example........ .....

Dim myPath As String = Server.MapPath( ".\Data\" +
Session("LogoFi leName"))

?myPath
"C:\Inetpub\www root\CPCustomer s\Data\GaryRock s.jpg"

the vb example works. the c# does not work. I notice that @ preceding
the string in the c# example. Could that be the difference? What am I
doing wrong in the C# example?


The only difference I see here is CSharpCustomers vs. CPCustomers, which I
hope is a typing error on your part, or else it makes no sense at all.

In C#, the @ means that backslashes in the string are not to be given
special interpretation.

So @"\" and "\\" in C# are both the same as "\" in Basic.

Jun 1 '06 #5
I have no idea why it cannot find the jpg. You are sure the jpg is in
BOTH folders?

Tina wrote:
Yes, I know that. That's why I put the extra back slashes in the c#
version. Have you any idea why the C# version canot find the jpg?
T


Jun 1 '06 #6
At the risk of pointing the obvious (which might not help anyway)...is your
VB project located in the same folder as your C# folder? The path returned by
MapPath will return the path under which it is run and the image must be
located in the data folder under that.

"Tina" wrote:
Yes, I know that. That's why I put the extra back slashes in the c#
version. Have you any idea why the C# version canot find the jpg?
T

"chanmm" <ch*****@hotmai l.com> wrote in message
news:%2******** ********@TK2MSF TNGP03.phx.gbl. ..
The backward slash (\) character can be used in a format string to turn
off the special meaning of
the character that follows it. For example, "\{" will cause a literal "{"
to be displayed, and "\\" will
display a literal "\". The at sign (@) character can be used to represent
an entire string verbatim. For
example, @"\\server\shar e" will be processed as \\server\share.

chanmm
"Tina" <ti**********@n ospammeexcite.c om> wrote in message
news:ej******** ********@TK2MSF TNGP02.phx.gbl. ..
I'm using 1.1/vs.net 2003 ...

C#example...... ........

string myPath = Server.MapPath( ".\\Data\\" + (string)
Session["LogoFileNa me"]);

Produces this value in myPath

?myPath
@"c:\inetpub\ww wroot\CSharpCus tomers\Data\Gar yRocks.jpg"

VB example........ .....

Dim myPath As String = Server.MapPath( ".\Data\" +
Session("LogoFi leName"))

?myPath
"C:\Inetpub\www root\CPCustomer s\Data\GaryRock s.jpg"

the vb example works. the c# does not work. I notice that @ preceding
the string in the c# example. Could that be the difference? What am I
doing wrong in the C# example?

thanks,
T



Jun 1 '06 #7
no. I found the problem to be something else and reposted "A strange c# -
vb difference"
sorry
T
"Mike Collins" <Mi*********@di scussions.micro soft.com> wrote in message
news:89******** *************** ***********@mic rosoft.com...
At the risk of pointing the obvious (which might not help anyway)...is
your
VB project located in the same folder as your C# folder? The path returned
by
MapPath will return the path under which it is run and the image must be
located in the data folder under that.

"Tina" wrote:
Yes, I know that. That's why I put the extra back slashes in the c#
version. Have you any idea why the C# version canot find the jpg?
T

"chanmm" <ch*****@hotmai l.com> wrote in message
news:%2******** ********@TK2MSF TNGP03.phx.gbl. ..
> The backward slash (\) character can be used in a format string to turn
> off the special meaning of
> the character that follows it. For example, "\{" will cause a literal
> "{"
> to be displayed, and "\\" will
> display a literal "\". The at sign (@) character can be used to
> represent
> an entire string verbatim. For
> example, @"\\server\shar e" will be processed as \\server\share.
>
> chanmm
>
>
> "Tina" <ti**********@n ospammeexcite.c om> wrote in message
> news:ej******** ********@TK2MSF TNGP02.phx.gbl. ..
>> I'm using 1.1/vs.net 2003 ...
>>
>> C#example...... ........
>>
>> string myPath = Server.MapPath( ".\\Data\\" + (string)
>> Session["LogoFileNa me"]);
>>
>> Produces this value in myPath
>>
>> ?myPath
>> @"c:\inetpub\ww wroot\CSharpCus tomers\Data\Gar yRocks.jpg"
>>
>>
>>
>> VB example........ .....
>>
>> Dim myPath As String = Server.MapPath( ".\Data\" +
>> Session("LogoFi leName"))
>>
>> ?myPath
>> "C:\Inetpub\www root\CPCustomer s\Data\GaryRock s.jpg"
>>
>> the vb example works. the c# does not work. I notice that @
>> preceding
>> the string in the c# example. Could that be the difference? What am
>> I
>> doing wrong in the C# example?
>>
>> thanks,
>> T
>>
>>
>
>


Jun 1 '06 #8

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

Similar topics

6
3752
by: cournape | last post by:
Hi there, I have some scientific application written in python. There is a good deal of list processing, but also some "simple" computation such as basic linear algebra involved. I would like to speed things up implementing some of the functions in C. So I need profiling. I first tried to use the default python profiler, but profiling my application multiplies the execution time by a factor between 10 and 100 ! So I decided to give a...
3
4608
by: Bill C. | last post by:
Hi, I've got a simple console app that just reads an XML file into a DataSet then prints out a description of each table in the DataSet, including column names and row values for each column. I'm getting some strange results depending the input XML file I use. I was wondering if somebody could help me understand what is going on or point me to a good reference. The code for my program looks like this:
25
3743
by: Neil Ginsberg | last post by:
I have a strange situation with my Access 2000 database. I have code in the database which has worked fine for years, and now all of a sudden doesn't work fine on one or two of my client's machines. The code opens MS Word through Automation and then opens a particular Word doc. It's still working fine on most machines; but on one or two of them, the user is getting an Automation Error. The code used is as follows: Dim objWord As...
31
6649
by: Bjørn Augestad | last post by:
Below is a program which converts a double to an integer in two different ways, giving me two different values for the int. The basic expression is 1.0 / (1.0 * 365.0) which should be 365, but one variable becomes 364 and the other one becomes 365. Does anyone have any insight to what the problem is? Thanks in advance. Bjørn
5
1694
by: cody | last post by:
I have a very funny/strange effect here. if I let the delegate do "return prop.GetGetMethod().Invoke(info.AudioHeader, null);" then I get wrong results, that is, a wrong method is called and I have no clue why. But if I store the MethodInfo in a local variable I works as expected. I do not understand why this is so, shouldn't both ways be semantically equal?
1
1356
by: Kepler | last post by:
I'm fighting a really strange bug that involves both a DataGrid and a Repeater disappearing on postback. The strange thing is that I've distilled the problem down to a simple program, that originally could reproduce the problem, but now can't, even as I add complexity back in. The basic scenario is a custom DataGrid (just make a class that derives from DataGrid) that has a LinkButton in a HeaderTemplate that has a CommandName="sort"...
1
1448
by: Martin Feuersteiner | last post by:
Dear Group I'm having a very weird problem. Any hints are greatly appreciated. I'm returning two values from a MS SQL Server 2000 stored procedure to my Webapplication and store them in sessions. Like This: prm4 = cmd1.CreateParameter With prm4
3
1468
by: skOOb | last post by:
I am having an issue right now of displaying the 'Age' of an item, but only on 1 computer. I can take my app and install it on multiple win98, winNT, and other winXP machines and have no problem. I install it on one computer (my boss's btw) and it doesn't work. I'll try and explain what I am trying to do. I am using MySQL 4.0.17 with VB.NET 2003. I need to calculate the difference of two dates, one of which is stored in the database,...
4
1223
by: kj | last post by:
I'm running into a strange seg fault with the module cjson. The strange part is that it does not occur when I run the code under Emacs' Pydb. Here's an example: import sys, cjson d1 = {'a': 1, 'b': 2, 'c': 3}
0
10216
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10049
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9865
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8873
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5310
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3965
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3565
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.