« Previous Next »

Thread: how do I stop and start an FTP site programmatically?

Last post 11-03-2009 6:52 AM by M.P. 3 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (4 items)

Sort Posts:

  • 11-02-2009, 8:17 AM

    • M.P
    • Not Ranked
    • Joined on 11-02-2009, 1:08 PM
    • Posts 3

    how do I stop and start an FTP site programmatically?

    I'm using FTP7 (or FTP7.5). I create an FTP site using MWA (C#), but when I try to get (ftpsite is a Site object):

    ftpsite.State

    it fails with exception: The object identifier does not represent a valid object. (Exception from HRESULT: 0x800710D8).

     It also fails on ftpsite.Stop and ftpsite.Start methods, but with no exception message.

    I've also noticed that in applicationHost.config, the attribute "serverAutoStart" has no effect on FTP sites.

     

    So how can I get FTP site state and stop or start it?

  • 11-02-2009, 12:36 PM In reply to

    • anilr
    • Top 10 Contributor
    • Joined on 05-23-2006, 10:13 PM
    • Redmond, WA
    • Posts 2,343

    Re: how do I stop and start an FTP site programmatically?

    Please look in ftp_schema.xml for properties methods related to ftp - the serverAutoStart/Start/Stop for ftp is under the ftpServer element.

    Anil Ruia
    Senior Software Design Engineer
    IIS Core Server
  • 11-03-2009, 4:58 AM In reply to

    • M.P
    • Not Ranked
    • Joined on 11-02-2009, 1:08 PM
    • Posts 3

    Re: how do I stop and start an FTP site programmatically?

    ok, thanks for the direction, I see those:

    <method name="Start" extension="Microsoft.ApplicationHostFtpConfigExtension" />
    <method name="Stop" extension="Microsoft.ApplicationHostFtpConfigExtension" />

    which are exactly what I need, but I still don't know how to call them from my managed code (do extensions need a special care?). Can you give me a simple code example for stopping an FTP site using a ServerManager object? That would be highly appreciated.

  • 11-03-2009, 6:52 AM In reply to

    • M.P
    • Not Ranked
    • Joined on 11-02-2009, 1:08 PM
    • Posts 3

    Re: how do I stop and start an FTP site programmatically?

    ok, I finally got it all together... This is how I got it done:

    using (ServerManager sm = new ServerManager())

    {

              ConfigurationElement ftp = sm.Sites[ftpSiteName].GetChildElement("ftpServer");

              ftp.Methods["Stop"].CreateInstance().Execute();

    }

    Thanks a lot for the hints!
Page 1 of 1 (4 items)
Microsoft Communities