Error 553 with my programs ftp file name not allowed
<p>I manage my youtube teams website and recently, the leader (and my friend) asked me to make him a program that can be used to update our sites news system dynamically. So I went to work creating a test php script that would display four html files using include that would display by date modified. That worked perfectly.</p>

<p>Now here's the problem. From the very start, the program has faced issues and errors. I've basically fixed each and every one of them except for this... Whenever I try to generate the file and ftp it to the test folder, I get the error(553): File name not allowed. I've tried everything I could thing of but, it doesn't work. I don't know if I am putting the sites ftp url wrong or what (as I am still quite new to using any form of c#, c++, or VB and still in high school) or if it's just the file name or path to the file that is screwed up but, I have spent the past two or three days trying to fix it and I have finally conceded defeat and am requesting help. I can supply my complete code for the functions:</p>

<pre><code>               UriBuilder ftpurl;
    static String ftpusername = "tmdev";
    static String ftppassword = "******";
    public static string GenerateFileName(string context)
    {
        return context + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + ".html";
    }
    public void openpic_Click(object sender, System.EventArgs e)
    {
        //Wrap the creation of the OpenFileDialog instance in a using statement,
        //Rather than manually calling the dispose method to ensure proper disposal
        using (OpenFileDialog dlg = new OpenFileDialog())
        {
            dlg.Title = "Open Image";
            dlg.Filter = "png files (*.png)|*.png";

            if (dlg.ShowDialog() == DialogResult.OK)
            {


                string folderName = @"c:\TMNGP_Web_Files";

                string pathString = folderName + @"\htTemp";
                pathString = pathString + @"\imgs";

                if (!System.IO.Directory.Exists(pathString))
                {
                    System.IO.Directory.CreateDirectory(pathString);
                }

                string destFileName = pathString + @"\" + dlg.SafeFileName.ToString();

                System.IO.File.Copy(dlg.FileName, destFileName, true);
                DisplImg.Image = new Bitmap(destFileName);
                DisplImg.ImageLocation = destFileName;
            }
        }


    }
    public void textgen_Click(object sender, System.EventArgs e)
    {

        string folderName = @"c:\TMNGP_Web_Files";

        string pathString = folderName + @"\htTemp";

        if (!System.IO.Directory.Exists(pathString))
        {
            System.IO.Directory.CreateDirectory(pathString);
        }

        string fileName = GenerateFileName("HT");

        pathString = pathString + @"\" + fileName;

        Console.WriteLine("Path to my file: {0}\n", pathString);

        if (!System.IO.File.Exists(pathString))
        {
            //System.IO.FileStream fs = System.IO.File.Create(pathString);
            using (System.IO.StreamWriter file = new System.IO.StreamWriter(pathString))
            {
                file.WriteLine("&lt;div class='simple_overlay' id='" + fileName + "' style='display:none;'&gt;");
                file.WriteLine("&lt;a class='close'&gt;&lt;/a&gt;");
                file.WriteLine("&lt;img src='" + DisplImg.ImageLocation.Substring(31) + "'/&gt;");
                file.WriteLine("&lt;div class='details'&gt;");
                file.WriteLine("&lt;h3&gt; " + txtTitle.Text + " &lt;/h3&gt;");
                file.WriteLine("&lt;h4&gt; " + TxtInfo.Text + " &lt;/h4&gt;");
                file.WriteLine("&lt;p&gt;" + Desctext.Text + "&lt;/p&gt;");
                file.WriteLine("&lt;/div&gt;");
                file.WriteLine("&lt;/div&gt;");
            }
                if(radioButton1.Checked)
                {
                    ftpurl = new UriBuilder("ftp", "tmngp.heliohost.org", 21, "NGP/test_folder/test_items/");
                }
                else
                {
                    ftpurl = new UriBuilder("ftp", "tmngp.heliohost.org", 21, "TM/test_folder/test_items/");
                }
            try
            {


                //string filenametwo = System.IO.Path.GetFullPath(@"c:\TMNGP_Web_Files\htTemp\"+fileName);
                string filenamethree = System.IO.Path.GetFullPath(DisplImg.ImageLocation.ToString());
                Console.WriteLine("{0}", filenamethree);
                Console.WriteLine(pathString);
                //string ftpfullpath = ftpurl;
                FtpWebRequest ftp = (FtpWebRequest)FtpWebRequest.Create((ftpurl + fileName).ToString());
                Console.WriteLine("{0}", ftpurl + fileName);
                ftp.Credentials = new NetworkCredential(ftpusername, ftppassword);
                ftp.KeepAlive = true;
                ftp.UseBinary = true;
                ftp.Method = WebRequestMethods.Ftp.UploadFile;
                StreamReader sourceStreamone = new StreamReader(@"c:\TMNGP_Web_Files\htTemp\" + fileName);
                byte[] fileContentsone = Encoding.UTF8.GetBytes(sourceStreamone.ReadToEnd());
                sourceStreamone.Close();
                ftp.ContentLength = fileContentsone.Length;
                Stream requestStreamone = ftp.GetRequestStream();
                requestStreamone.Write(fileContentsone, 0, fileContentsone.Length);
                requestStreamone.Close();
                FtpWebResponse ftpresponseone = (FtpWebResponse)ftp.GetResponse();
                Console.WriteLine("Upload File Complete, status {0}", ftpresponseone.StatusDescription);
                ftpresponseone.Close();



            }
            catch (WebException ex)
            {
                throw ex;
            }
            try
            {
                FtpWebRequest ftp2 = (FtpWebRequest)FtpWebRequest.Create(ftpurl + Path.GetFileName(DisplImg.ImageLocation.ToString()));
                ftp2.Credentials = new NetworkCredential(ftpusername, ftppassword);
                ftp2.KeepAlive = true;
                ftp2.UseBinary = true;
                ftp2.Method = WebRequestMethods.Ftp.UploadFile;
                StreamReader sourceStreamtwo = new StreamReader(DisplImg.ImageLocation.ToString());
                byte[] fileContentstwo = Encoding.UTF8.GetBytes(sourceStreamtwo.ReadToEnd());
                sourceStreamtwo.Close();
                ftp2.ContentLength = fileContentstwo.Length;
                Stream requestStreamtwo = ftp2.GetRequestStream();
                requestStreamtwo.Write(fileContentstwo, 0, fileContentstwo.Length);
                requestStreamtwo.Close();
                FtpWebResponse ftpresponsetwo = (FtpWebResponse)ftp2.GetResponse();
                Console.WriteLine("Upload File Complete, status {0}", ftpresponsetwo.StatusDescription);
                ftpresponsetwo.Close();
            }
            catch(Exception ex)
            {
                throw ex;
            }


        }
        else
        {
            Console.WriteLine("File \"{0}\" already exists.", fileName);
            return;
        }
    }
</code></pre>

<p>If you can supply any help I would appreciate it very much.</p>
