<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body class='hmmessage'>Thanks Martin, I wanted to avoid 'rolling my own' as you have done. And also, I'm lazy,.... with the edtftp class I can do simple stuff like:<BR>
 <BR>
                // FTP 'put' this file to the backend<BR>                ftpConnection1.UploadFile(Resources.LocalFolder + "/" + name, name);<BR><BR>
                // Rename the .GET to be .FET<BR>                ftpConnection1.RenameFile(name, name.Replace(".GET", ".FET"));<BR><BR>
I have never been a fan of object orientation, but when C# and it's classes certain make me think again....<BR>
<BR><BR> <BR>

<HR id=stopSpelling>
<BR>
> Subject: Re: [Simh] FTP client connecting to SIMH/OpenVMS?<BR>> Date: Thu, 12 Jun 2008 08:52:57 +0200<BR>> From: MV@PDV-SYSTEME.DE<BR>> To: simh@trailing-edge.com<BR>> CC: petermoreton@hotmail.co.uk<BR>> <BR>> Peter,<BR>> <BR>> > I'm struggling to get a simple client program running <BR>> > on a PC to be able to FTP a file to/from OpenVMS 7.1 running <BR>> > under SIMH. The issue is simple: the Microsoft .NET 2.0 FTP <BR>> > class fesses-up when confronted with VMS directory names. It <BR>> > basically doesn't work, and Microsoft have acknowledged this <BR>> > as an issue.<BR>> > <BR>> > I'm just wondering if anyone else on the list has solved this <BR>> > problem, of how to write a simple Windows program to get <BR>> > files in/out of VMS, using c# / DotNet etc.<BR>> <BR>> No idea what the "Microsoft .NET 2.0 FTP class" looks like, but<BR>> here's something I wrote that uses the WinInet FTP functions<BR>> to get all files in a directory (beware of lines wrapping).<BR>> <BR>> HTH,<BR>> Martin<BR>> <BR>> <BR>> /*<BR>> Format of FtpFindFirstFile/InternetFindNextFile is the same as an FTP DIR, that is:<BR>> <BR>> Ftp> dir sys$manager:decw*.com<BR>> <BR>> Directory SYS$SYSROOT:[SYSMGR]<BR>> <BR>> DECW$KILLSERVER0.COM;1 No privilege for attempted operation<BR>> DECW$PRIVATE_APPS_SETUP.COM;2 No privilege for attempted operation<BR>> DECW$PRIVATE_APPS_SETUP.COM;1 No privilege for attempted operation<BR>> <BR>> Total of 3 files, 0/0 blocks<BR>> <BR>> Directory SYS$COMMON:[SYSMGR]<BR>> <BR>> DECW$CONSOLE.COM;1 3/3 29-MAR-2000 07:32:20 [FIELD,SYSTEM] (RWED,RWED,RE,RE)<BR>> DECW$DEFAULT_DESKTOP.COM;1<BR>> 1/3 29-JAN-2004 15:50:06 [FIELD,SYSTEM] (RWED,RWED,RE,RE)<BR>> DECW$DEVICE.COM;1 56/57 1-OCT-2003 22:04:23 [FIELD,SYSTEM] (RWED,RWED,RE,RE)<BR>> DECW$DEVICE_CONFIG_COMMON.COM;1<BR>> 6/6 5-JAN-1994 13:08:13 [FIELD,SYSTEM] (RWED,RWED,RE,RE)<BR>> ...<BR>> <BR>> Total of 30 files, 384/420 blocks<BR>> <BR>> Grand total of 2 directories, 33 files, 384/420 blocks<BR>> <BR>> Ftp><BR>> <BR>> <BR>> except that blank lines are skipped.<BR>> <BR>> */<BR>> int GetFiles(HINTERNET hConnection, LPSTR pattern) {<BR>> HINTERNET hFindFile = NULL;<BR>> WIN32_FIND_DATA FindFileData;<BR>> int rc = ERROR_SUCCESS;<BR>> char fspec[_MAX_PATH],<BR>> lastspec[_MAX_PATH] = "",<BR>> *p;<BR>> BOOL continuation_line = FALSE;<BR>> <BR>> hFindFile = FtpFindFirstFile(hConnection, "*.*", &FindFileData, INTERNET_FLAG_RELOAD, 0);<BR>> if (! hFindFile)<BR>> return(ProcessError("FindFirstFile"));<BR>> <BR>> do {<BR>> if (verbosity > 2)<BR>> fprintf(stderr, " %s\n", FindFileData.cFileName);<BR>> if (continuation_line) {<BR>> continuation_line = FALSE;<BR>> continue;<BR>> }<BR>> strcpy(fspec, FindFileData.cFileName);<BR>> /*<BR>> if (fspec[0] == ' ') // continuation line<BR>> continue;<BR>> */<BR>> if (strncmp(fspec, "Directory ", sizeof("Directory ")) == 0) // directory line<BR>> continue;<BR>> if (strncmp(fspec, "Total of ", sizeof("Total of ")) == 0) // statistics line<BR>> continue;<BR>> if (strncmp(fspec, "Grand total of ", sizeof("Grand total of ")) == 0) // statistics line<BR>> continue;<BR>> if (strchr(fspec, ' ') == NULL) // no complete entry<BR>> continuation_line = TRUE;<BR>> _strupr(fspec);<BR>> if ((p = strchr(fspec,';')) != NULL) // strip semicolon and everything after it<BR>> *p = '\0';<BR>> if (strcmp(fspec, lastspec) == 0) // multiple versions of the same file<BR>> continue;<BR>> strcpy(lastspec, fspec);<BR>> if (strcmp(&fspec[strlen(fspec)-4], ".DIR") == 0) // sub-directory entry<BR>> continue;<BR>> if (! match(pattern, fspec)) // no match?<BR>> continue;<BR>> <BR>> if (verbosity > 0)<BR>> fprintf(stderr, "GETting file %s\n", fspec);<BR>> <BR>> if (!(opt & OPT_M_NOCOPY) && ! FtpGetFile(<BR>> hConnection, // connection handle<BR>> fspec, // remote file<BR>> fspec, // local file name<BR>> FALSE, // fail if exists?<BR>> FILE_ATTRIBUTE_NORMAL, // CreateFile() flags<BR>> FTP_TRANSFER_TYPE_ASCII // flags<BR>> | INTERNET_FLAG_RELOAD,<BR>> 0 // context<BR>> )) {<BR>> rc = ProcessError("FtpGetFile");<BR>> break;<BR>> }<BR>> strcat(fspec, ";"); // UCX FTP DEL needs a semicolon<BR>> if (!(opt & OPT_M_NODELETE) && ! FtpDeleteFile(hConnection, fspec)) {<BR>> rc = ProcessError("FtpDeleteFile");<BR>> break;<BR>> }<BR>> }<BR>> while (InternetFindNextFile(hFindFile, &FindFileData));<BR>> <BR>> if (rc == ERROR_SUCCESS && GetLastError() != ERROR_NO_MORE_FILES)<BR>> ProcessError("InternetFindNextFile");<BR>> <BR>> InternetCloseHandle(hFindFile);<BR>> <BR>> return(rc);<BR>> }<BR>> <BR>> -- <BR>> O Lord, won't you buy me | Martin Vorlaender | OpenVMS rules!<BR>> an HP OS | work: mv@pdv-systeme.de<BR>> its name starts with "Open" | http://vms.pdv-systeme.de/users/martinv/<BR>> and ends in "VMS" ... | home: martin.vorlaender@t-online.de <BR><BR><br /><hr />Get 5GB of online storage for free! <a href='http://clk.atdmt.com/UKM/go/msnnkmgl0010000005ukm/direct/01/' target='_new'>Get it Now! </a></body>
</html>