Create FTP virtual directory programmatically

  • Thread starter Thread starter Lan H. Nguyen
  • Start date Start date
L

Lan H. Nguyen

I am trying to create a ftp virtual directory for every new user that
registers using snippet code below and got an access denied error right on
this line deRoot.RefreshCache();
I tried to have impersonate=true in web.config but still not working.
I am using window server 2003 and vs 2003. Any pointers would be
appreciated.

Lan

public void CreateVirtualDirectory()
{
string schema = "IIsFtpVirtualDir";
string rootSubPath = "/MSFTPSVC/1/Root";

DirectoryEntry deRoot= new DirectoryEntry("IIS://" + m_MachineName +
rootSubPath);

deRoot.RefreshCache();
DirectoryEntry deNewVDir = deRoot.Children.Add( m_DirName, schema );

deNewVDir.Properties["Path"].Insert(0, m_DirPath);
deNewVDir.CommitChanges();
deRoot.CommitChanges();

deNewVDir.Close();
deRoot.Close();
}
 
Back
Top