/// <summary>
        /// Creates virtual directory under site with given name and sets authorization rules.
        /// </summary>
        /// <param name="siteName">Site name.</param>
        /// <param name="account">Account information.</param>
        public void CreateFtpAccount(string siteName, FtpAccount account)
        {
            Site site = this.GetIisSite(siteName);

            if (site != null)
            {
                Application application = site.Applications["/"];
                if (application != null)
                {
                    // Convert FTP account name to virtual directory format
                    var ftpVirtualDir = String.Format("/{0}", account.Name);
                    //
                    VirtualDirectory accountDirectory = application.VirtualDirectories[ftpVirtualDir];
                    //
                    if (accountDirectory != null)
                    {
                        application.VirtualDirectories.Remove(accountDirectory);
                    }
                    VirtualDirectory createdVirtualDirectory = application.VirtualDirectories.Add(ftpVirtualDir, account.Folder);


                    AuthorizationRuleCollection authRulesCollection = this.GetAuthorizationRuleCollection(String.Format("{0}/{1}", siteName, account.Name));
                    List <AuthorizationRule>    rulesToRemove       = new List <AuthorizationRule>();
                    foreach (AuthorizationRule rule in authRulesCollection)
                    {
                        if (rule.AccessType == AuthorizationRuleAccessType.Allow && (rule.Users == "?" || rule.Users == "*"))
                        {
                            rulesToRemove.Add(rule);
                        }
                    }

                    foreach (AuthorizationRule rule in rulesToRemove)
                    {
                        authRulesCollection.Remove(rule);
                    }

                    PermissionsFlags permissions = 0;
                    if (account.CanRead)
                    {
                        permissions |= PermissionsFlags.Read;
                    }
                    if (account.CanWrite)
                    {
                        permissions |= PermissionsFlags.Write;
                    }
                    if (account.CanRead || account.CanWrite)
                    {
                        authRulesCollection.Add(AuthorizationRuleAccessType.Allow, account.Name, String.Empty, permissions);
                    }
                }
            }
            this.CommitChanges();
        }