SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast newsomer's Avatar
    Join Date
    Oct 2001
    Location
    Southwestern Georgia, USA
    Posts
    60
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Server.MapPath and File/Folder Names With Commas

    This is probably an old problem but my search did not lead me to an answer here.

    The Windows OS allows commas in file/folder names but if you try to call
    Code:
    Server.MapPath("/smith, john/")
    your application will neatly halt and provide you with an error report.

    Other than telling your site/network users not to use commas as allowed in the OS what can the application designer do to avoid the error.

    I am sure a kludgey workaround is to scan for the comma, change the file/folder name to something safe then restore the name at the end. I don't think this is a safe way to do things though.

    Thanks.

  2. #2
    SitePoint Zealot -rob-'s Avatar
    Join Date
    Mar 2003
    Location
    Earth
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Please post the error report here.
    Cheers,

    -rob-

  3. #3
    SitePoint Enthusiast newsomer's Avatar
    Join Date
    Oct 2001
    Location
    Southwestern Georgia, USA
    Posts
    60
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by -rob-
    Please post the error report here.
    As requested:



    The page cannot be displayed

    There is a problem with the page you are trying to reach and it cannot be displayed.



    . . .



    Technical Information (for support personnel)

    • Error Type:
      Server.MapPath(), ASP 0173 (0x80004005)
      An invalid character was specified in the Path parameter for the MapPath method.
      /yadayadayada/Default.asp, line 17

    • Browser Type:
      Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; Avant Browser [avantbrowser.com]; .NET CLR 1.0.3705; .NET CLR 1.1.4322)
    • Page:
      GET /yadayadayada/Default.asp
    • Time:
      Tuesday, November 25, 2003, 2:00:44 PM


    • More information:
      Microsoft Support



    I have verified this is a previously identified problem but have not found a useful solution.
    Thanks again . . .
    There are three types of people.
    Those that can count and
    those that cannot.

  4. #4
    SitePoint Wizard
    Join Date
    Jan 2001
    Location
    Milton Keynes, UK
    Posts
    1,011
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It looks like it's a known (and unfixed) problem. The following solution was found at Using Server.Mappath().

    Code:
    <%
        dumb_folder_name = "/comma,comma/"
        webroot = server.mappath("/")
        fullpath = webroot & replace(dumb_folder_name,"/","\")
    %>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •