Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE
WPita_MMSIS Super Contributor.
Super Contributor.
489 views

Files in ftp folder

Jump to solution
I need to convert this FTP Folder routine to Cobol, can anyone help? Thank you!

FtpWebRequest fwrr = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://" + server + path)); fwrr.Credentials = new NetworkCredential(user,pass); fwrr.Method = WebRequestMethods.Ftp.ListDirectory; StreamReader srr = new StreamReader(fwrr.GetResponse().GetResponseStream()); string str = srr.ReadLine(); List<string> strList = new List<string>(); while (str != null) { strList.Add(str); //strList.Add(string.Format("ftp://{0}/{1}/{2}",server,path,str)); str = srr.ReadLine(); } foreach (var item in strList) { Console.WriteLine(item.ToString()); } Console.ReadLine();

I also need to download a file that is on ftp
0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Files in ftp folder

Jump to solution

This would translate to COBOL as something like the following:

 

           declare server path #user pass as string
           declare fwrr as type FtpWebRequest = type FtpWebRequest::Create(new type Uri("ftp://" & server & path)) as type FtpWebRequest
           set fwrr::Credentials = new NetworkCredential(#user, pass)
           set fwrr::Method to type WebRequestMethods+Ftp::ListDirectory
           declare srr as type  StreamReader = new StreamReader(fwrr::GetResponse()::GetResponseStream())
           declare str as  string = srr::ReadLine
           declare strList as type  List[string]  = new type List[string]
           perform until str = null
              invoke strList::Add(str)
                *>strList.Add(string.Format("ftp://{0}/{1}/{2}",server,path,str));
              set str = srr::ReadLine
           end-perform
           perform varying item as string thru strList 
              invoke type Console::WriteLine(item::ToString)
           end-perform
           invoke type Console::ReadLine
1 Reply
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Files in ftp folder

Jump to solution

This would translate to COBOL as something like the following:

 

           declare server path #user pass as string
           declare fwrr as type FtpWebRequest = type FtpWebRequest::Create(new type Uri("ftp://" & server & path)) as type FtpWebRequest
           set fwrr::Credentials = new NetworkCredential(#user, pass)
           set fwrr::Method to type WebRequestMethods+Ftp::ListDirectory
           declare srr as type  StreamReader = new StreamReader(fwrr::GetResponse()::GetResponseStream())
           declare str as  string = srr::ReadLine
           declare strList as type  List[string]  = new type List[string]
           perform until str = null
              invoke strList::Add(str)
                *>strList.Add(string.Format("ftp://{0}/{1}/{2}",server,path,str));
              set str = srr::ReadLine
           end-perform
           perform varying item as string thru strList 
              invoke type Console::WriteLine(item::ToString)
           end-perform
           invoke type Console::ReadLine
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.