After looking all the ways to progrrammatically create a new FTP Server &
Virtual Directory, I have come to see that the code below is the cleanest.
Here is my basic issue. When I run this code, I successfully create a new
FTP Server and virtual directory. The strange this is that the description
of the new server is (Stopped) and the status has the following warning "The
specified metadata was not found.". If I manually Stop the individual
server and restart it, it comes back clean and all is well. No matter what
I do, I cannot get it to create successfully in a Running state. This exact
same code, except for the different properties, works for creating a new Web
Site and does so without complaint. All of this is on a Windows 2003 server
using .NET v1.1 completely packed and up to date. The physical path exists
and it is not permissions.
Any help or insight would be greatly appreciated!
private void CreateFTP()
{
DirectoryEntry root = new DirectoryEntry("IIS://localhost/MSFTPSVC");
// Create web site
Random r = new Random();
int siteID = r.Next(100000000, 1000000000);
DirectoryEntry site = (DirectoryEntry)root.Invoke("Create",
"IIsFtpServer", Convert.ToString(siteID));
site.Invoke("Put", "ServerComment", "test.com");
site.Invoke("Put", "ServerBindings", "64.16.143.2:21:");
site.Invoke("SetInfo");
// Create virtual directory
DirectoryEntry siteVDir = site.Children.Add("ROOT", "IISFtpVirtualDir");
siteVDir.Properties["Path"][0] = "d:\\internet2\\www\\test";
siteVDir.CommitChanges();
site.CommitChanges();
}
Thx in Advance - Jamie