Hi,
Now I can log on to the FTP Server whats the COBOL code to send a small text file.
Thanks
Neil.
Hi,
Now I can log on to the FTP Server whats the COBOL code to send a small text file.
Thanks
Neil.
Hi,
Now I can log on to the FTP Server whats the COBOL code to send a small text file.
Thanks
Neil.
I haven't used the .NET Framework's FtpWebRequest class, which is what you're using, according to your previous question. But from the Microsoft documentation, it looks like the general procedure for any FTP operation using that class is:
Hi,
Now I can log on to the FTP Server whats the COBOL code to send a small text file.
Thanks
Neil.
i have taken your code above and converted into cobol and it all converts (i think) apart from one line can you pls advise.
point 4 Write the file contents to the request stream.
invoke fileStream::CopyTo(requestStream)
01 cFtpWebRequest type "System.Net.FtpWebRequest".
01 cStream type "System.IO.Stream".
01 cFileStream type "System.IO.FileStream".
01 cWebResponse type "System.Net.WebResponse".
* set cFtpWebRequest::Method to type WebRequestMethods::Ftp::UploadFile
set cFtpWebRequest::"Method" to type "System.Net.WebRequestMethods Ftp"::"UploadFile"
* set requestStream to cFtpWebRequest::RequestStream
set cStream to cFtpWebRequest::"GetRequestStream"()
* invoke fileStream::CopyTo(requestStream)
invoke cFileStream::
* invoke requestStream::Close
invoke cFileStream::"Close"()
* set webResponse to cFtpWebRequest::GetResponse
set cWebResponse to cFtpWebRequest::"GetResponse" as cFtpWebResponse
Hi,
Now I can log on to the FTP Server whats the COBOL code to send a small text file.
Thanks
Neil.
It would use cStream as this is the return value from GetRequestStream method.
set cStream to cFtpWebRequest::"GetRequestStream"()
invoke cFileStream::CopyTo(cStream)
Hi,
Now I can log on to the FTP Server whats the COBOL code to send a small text file.
Thanks
Neil.
CopyTo
does not come up as an option (in visual cobol IDE) after i have type in
invoke cFileStream::
Hi,
Now I can log on to the FTP Server whats the COBOL code to send a small text file.
Thanks
Neil.
It does show CopyTo as an available method for me.
What does show in intellisense for available methods?
Are you using .Net Framework 4?
Try typing the statement anyway without intellisense and see if it shows a syntax error or not.
Hi,
Now I can log on to the FTP Server whats the COBOL code to send a small text file.
Thanks
Neil.
im using .net framework 3.5 which i guess is the problem.
but there must be ftp code that supports this version of .net, or is there a winapi way of send a small text file via ftp?
or some other way ..... its so close :(
Hi,
Now I can log on to the FTP Server whats the COBOL code to send a small text file.
Thanks
Neil.
The following works with .NET Framework 3.5 if you must use it:
$set ilusing"System.Net"
$set ilusing"System.IO"
program-id. Program1 as "testftp.Program1".
data division.
working-storage section.
01 cFtpWebRequest type System.Net.FtpWebRequest.
01 cFtpWebResponse type System.Net.FtpWebResponse.
01 cFileInfo type FileInfo.
01 fileContents type Byte occurs any.
01 cFileStream type FileStream.
01 writer type Stream.
procedure division.
try
set cftpWebRequest to type FtpWebRequest::Create(new type Uri("ftp.microfocus.com/testfile.txt")) as type FtpWebRequest
set cFtpWebRequest::Method to type "System.Net.WebRequestMethods Ftp"::"UploadFile"
set cftpWebRequest::Proxy to null
set cftpWebRequest::UseBinary to true
set cftpWebRequest::Credentials to new NetworkCredential("user", "password")
set cFileInfo to new FileInfo("c:\\\\temp\\\\testfile.txt") *>e.g.: c:\\\\Test.txt
set size of fileContents to cFileInfo::Length
set cFileStream to cFileInfo::OpenRead
invoke cFileStream::Read(fileContents, 0, type Convert::ToInt32(cFileInfo::Length))
set writer to cftpWebRequest::GetRequestStream
invoke writer::Write(fileContents, 0, fileContents::Length)
invoke writer::Close
set cftpWebResponse to cFtpWebRequest::GetResponse as type FtpWebResponse
display cftpWebResponse::StatusDescription
catch ex as type WebException
display ex::Message
end-try
goback.
Hi,
Now I can log on to the FTP Server whats the COBOL code to send a small text file.
Thanks
Neil.
Hi Chris,
Thanks for your help with this much appreciated, one slight problem, it fails on the following line (jumps to the catch):-
set writer to cftpWebRequest::GetRequestStream
With the following message:-
The requested URI is invalid for this FTP command
It also leaves the "writer" field set to NULL
Any idea whats wrong.
Thanks
Neil.
Hi,
Now I can log on to the FTP Server whats the COBOL code to send a small text file.
Thanks
Neil.
Hi Chris,
Sorry forget above I missed a line out ..... DOH.
Testing now.
Thanks
Neil.
Hi,
Now I can log on to the FTP Server whats the COBOL code to send a small text file.
Thanks
Neil.
I see that with assistance from Chris you have this working now. I just wanted to point out that my sample code was COBOL - I was using the syntax supported by the current Visual COBOL, including unquoted method names (though some of your changes might be necessary there too; I hadn't compiled the sample code). And, as noted elsewhere in the thread, the Stream::CopyTo method is available in .NET Framework 4. Mentioning what version of Visual COBOL and .NET Framework you're using when you post a question can help avoid some confusion.
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.