FtpWebRequest method=Create Directory problem with "#" in the directory name.

When i try to create a directory on a server with FTPWEBREQUEST with a # character in the directory name it only creates the directory name up until the # character.

For example if i try to create the directory "C# Express" only "C" gets created on the server.

I if send "C++ Express" it creates "C++ Express" on the server.

I'm going to check into other characters that are valid for a directory name but don't get created with FTPWEBREQUEST.

lushdog



Answer this question

FtpWebRequest method=Create Directory problem with "#" in the directory name.

  • azuomar73

    Did some more research on this, seems to be the expected way to handle it so basically you can do this to format it properly.

    'format into acceptable url format

    myString = URLEncode(myURL)

    myStringBuilder.Append(myString)

    'replace "+" with escape for space

    myStringBuilder.Replace("+","%20")

    thanks for the help,

    lushdog


  • dtwilliamson

    What is the URL you are using when you are
    creating these requests

  • CE

    Did you try escaping the char # with %23

  • yaaaar

    It seems that that class is only for ASP   I can't get it to show in my vb.net app no matter what i import.

    ***No worries i found it, i had to add a reference to system.web.dll to get it to work***


  • dma550

    You can use
    System.Web.HttpUtility.UrlEncode class

  • Rik Dodsworth

    I'll try that but my directory names are coming in through a dialog box so i'll have to rewrite some code to fire it out.

    Any word on that other thing


  • hengemd

    serverString = "ftp://" + userName + ":" + password + "@" + serverAddress + ":" + serverPort + "/" + directorySB.ToString

    directorySB being the directory i want to create on the server.
    Basically i try to send the settings folder in my Visual Studio 2005 folder.

  • Ankini

    Still getting some funny errors when i use that functions.

    For spaces in the source directory name, "+" get put in the targer directory's name. I'm checking into wether this is a server specific error or a .net problem.


  • FtpWebRequest method=Create Directory problem with "#" in the directory name.