Home Forums ActiveX components Xceed FTP for ActiveX Check if file exists?

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #42633 |

    How do I check if a file exists before I attempt to delete it using the XCeed FTP Control?

    Is it necessary?

    If File X exists I want to delete it.

    If I call

    XFTP.DeleteFile(“File X”)

    and the file does not exist will I get an error?

    Thanks,
    Shan

    Imported from legacy forums. Posted by RDC (had 6465 views)

    User (Old forums)
    Member
    Post count: 23064

    Hello RDC.

    If you call DeleteFile on a file that does not exist, the server with indeed return an error reply, and the method will fail with an error. The reply code affects the error we return, but it should normally be FTP_E_OPENREMOTEFILE (0x80042013). But then again, a server could decide to return the same reply if you don’t have the rights to delete that file, or if it’s in use, etc.

    To make sure the file is there, you can call GetFolderContents with that filename as the mask. The method should return one entry if the file exists, or none if it doesn’t.

    Imported from legacy forums. Posted by Martin (had 546 views)

    User (Old forums)
    Member
    Post count: 23064

    I am getting various run-time errors when the mainframe file I am trying to download is either empty, has not been defined, or was open in another partition. I read this posting and decided to try the GetFolderContents to determine if a mainframe file exists before running FTP1.ReceiveFile. I assumed it was part of the package but of course got the “function not defined” error. Is there another way to test for the various run-time errors (indicating that the file is not there) prior to executing the receive command??

    Imported from legacy forums. Posted by SCJ (had 537 views)

    User (Old forums)
    Member
    Post count: 23064

    I don’t understand why you get that “Function not defined”, since the GetFolderContents method is indeed part of the Xceed FTP Library:

    <a href=”http://doc.xceedsoft.com/products/Ftp/sources/getfoldercontents_method.htm”>http://doc.xceedsoft.com/products/Ftp/sources/getfoldercontents_method.htm</a&gt;

    Imported from legacy forums. Posted by Martin (had 417 views)

    User (Old forums)
    Member
    Post count: 23064

    Thank you for the quick response. I got the error message because I did not have the GetFolderContents syntax correct. Now that I have fixed that problem, what will I get back from an MVS mainframe? If I use the shortname of the mainframe file I am downloading as the mask name, will I get a zero if the file is there and something else if it’s not?

    Imported from legacy forums. Posted by SCJ (had 5492 views)

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.