Mainframe upload: GDG name conversion failed

Dec 2, 2013 at 6:58 PM
Edited Dec 2, 2013 at 7:08 PM
Edit: Short answer, I didn't wrap my dataset name with single quotes inside the string. This question is solved.

I'm trying to upload a file to a mainframe dataset, but am currently getting this exception when I call the "OpenWrite" method below, with a valid dataset:

System.Net.FtpClient.FtpCommandException: Requested action not taken: GDG name conversion failed.
at System.Net.FtpClient.FtpClient.OpenPassiveDataStream(FtpDataConnectionType type, String command, Int64 restart)
at System.Net.FtpClient.FtpClient.OpenDataStream(String command, Int64 restart)
at System.Net.FtpClient.FtpClient.OpenWrite(String path, FtpDataType type)
at System.Net.FtpClient.FtpClient.OpenWrite(String path)

                byte[] fileBytes = File.ReadAllBytes(tempFile);
                using (var test = new FtpClient())
                    test.Host = "host";
                    test.Credentials = new NetworkCredential("user", "pass");
                    test.Port = 21;
                    test.Execute("site recfm=fb");
                    test.Execute("site lrecl=60");
                    using (var writeStream = test.OpenWrite(@""))
                        writeStream.Write(fileBytes, 0, fileBytes.Length);
            catch (Exception e)
Marked as answer by talz13 on 12/2/2013 at 11:07 AM