468,507 Members | 1,537 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,507 developers. It's quick & easy.

Request.QueryString and "&" in Folder Name

Not sure where to ask this question, but...
I'm using a TreeView component to enable browsing file folders in a
specific directory (for test purposes /Program Files/). Some users use
an ampersand ("&") in both folder and file names. This has caused me
some real grief! I'm not in a position to tell the users it's an ID 10
T error and they have to change their file and folder names.
In VS2K5, I have debugged my code and found that

sender.base.Request.QueryString =
{dir=%2fProgram+Files%2fMom+&amp%3b+Pop%2f}

and

sender.base.Request.RawURL="/popups/share_directory/XmlFromFileSystem.aspx?dir=/Program%20Files/Mom%20&%20Pop/"

These results reflecting a file folder /Program Files/Mom & Pop/

However, the code line:

sdir = Request.QueryString["dir"]

gives me /Program Files/Mom (space after Mom is included). In other
words, everything from the ampersand on, including the ampersand, is
truncated. The "&amp%3b" you see in the QueryString is my attempt to
escape the ampersand. I've also tried /& to no avail.

At this point, the boss thinks I'm a loser! Any help would be greatly
appreciated!
Asp.NET 2.0, VS 2005.
Randy

May 8 '06 #1
1 2626
Just use URLencode when you generate the url ...
http://msdn2.microsoft.com/en-us/lib...6w(VS.80).aspx you can
urldecode it when you get it back. It supports amspersands without issue.

Cheers,

Greg
"EoRaptor013" <rc*******@patmedia.net> wrote in message
news:11**********************@y43g2000cwc.googlegr oups.com...
Not sure where to ask this question, but...
I'm using a TreeView component to enable browsing file folders in a
specific directory (for test purposes /Program Files/). Some users use
an ampersand ("&") in both folder and file names. This has caused me
some real grief! I'm not in a position to tell the users it's an ID 10
T error and they have to change their file and folder names.
In VS2K5, I have debugged my code and found that

sender.base.Request.QueryString =
{dir=%2fProgram+Files%2fMom+&amp%3b+Pop%2f}

and

sender.base.Request.RawURL="/popups/share_directory/XmlFromFileSystem.aspx?dir=/Program%20Files/Mom%20&amp;%20Pop/"

These results reflecting a file folder /Program Files/Mom & Pop/

However, the code line:

sdir = Request.QueryString["dir"]

gives me /Program Files/Mom (space after Mom is included). In other
words, everything from the ampersand on, including the ampersand, is
truncated. The "&amp%3b" you see in the QueryString is my attempt to
escape the ampersand. I've also tried /& to no avail.

At this point, the boss thinks I'm a loser! Any help would be greatly
appreciated!
Asp.NET 2.0, VS 2005.
Randy

May 8 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

23 posts views Thread by ian justice | last post: by
3 posts views Thread by Arpan | last post: by
4 posts views Thread by barney | last post: by
5 posts views Thread by martin | last post: by
2 posts views Thread by Mehdi | last post: by
2 posts views Thread by beachboy | last post: by
1 post views Thread by EoRaptor013 | last post: by
3 posts views Thread by Tanmaya Kulkarni | last post: by
3 posts views Thread by gieforce | last post: by
1 post views Thread by fmendoza | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.