Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7979111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T09:41:11+00:00 2026-06-04T09:41:11+00:00

I have created a web setup for my web service application and managed to

  • 0

I have created a web setup for my web service application and managed to deploy successfully. However, the web setup will always create my virtual directory under the inetpub\wwwroot directory (which happens to be in my C-drive).

Is there anyway I can make the web setup create the virtual
directory in another location, eg, d-drive as my client have wwwroot in d drive. I have tried to remove the installation address step of the web setup, but it still default to inetpub\wwwroot.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T09:41:12+00:00Added an answer on June 4, 2026 at 9:41 am

    Here’s some code I wrote which will give you an idea of how I create a virtual directory. I’ve just included the code as I wrote it, so there are a couple of leaps of faith in there. But hopefully the inbound parameters are obvious (although note that the method expects that you know the ID of the web site). Check out also the second method (called by the first) – these two methods in combination will allow you to access an existing site’s existing virtual directory, and to set various properties including the “Path” property.

    Hope this helps you along the way…

        /// <summary>
        /// Creates a virtual directory on the specified web site
        /// </summary>
        /// <param name="serverName">name of server</param>
        /// <param name="siteId">Site Id</param>
        /// <param name="directoryName">Virtual Directory Name</param>
        /// <param name="physicalPath">physical path of directory</param>
        /// <param name="bAnonymousLogon">Integrated Windows authentication or Anonymous Logon</param>
        /// <param name="defaultDoc">The default document for the site.</param>
        /// <returns>The Virtual Directory</returns>
        public DirectoryEntry CreateVirtualDirectory(string serverName, int siteId, string directoryName, string physicalPath, bool bAnonymousLogon, string defaultDoc)
        {
            try
            {
                // Does the directory exist already?
                DirectoryEntry vDir = GetVirtualDirectory(serverName, siteId, directoryName);
    
                if (vDir != null)
                {
                    // Yes, it does, no need to create
                    _Logger.Log(String.Format(CultureInfo.CurrentUICulture, VirDirAlreadyExists, directoryName, siteId));
                }
                else
                {
                    // No, we have some creating to do
                    DirectoryEntry root = new DirectoryEntry("IIS://" + serverName + "/W3SVC/" + siteId.ToString(CultureInfo.CurrentUICulture) + "/Root");
                    vDir = root.Children.Add(directoryName, IisVirtualDirectory);
                    vDir.CommitChanges();
                    _Logger.Log(String.Format(CultureInfo.CurrentUICulture, VirDirCreated, directoryName, siteId));
                }
    
                // Created or not, we want to set the virtual directory's properties
                // We take a risk here by using literals rather than variables (need to make sure the
                // log value is the same as the actual entry)
                // But its not really much of a risk - the main reason for logging is to record progress
                // through the "set" operation
    
                _Logger.Log(String.Format(CultureInfo.CurrentUICulture, VirDirCreatePath, physicalPath));
                vDir.Properties["Path"][0] = physicalPath;
    
                _Logger.Log(String.Format(CultureInfo.CurrentUICulture, VirDirCreateAccessRead, true.ToString(CultureInfo.CurrentUICulture)));
                vDir.Properties["AccessRead"][0] = true;
    
                _Logger.Log(String.Format(CultureInfo.CurrentUICulture, VirDirCreateAccessExecute, true.ToString(CultureInfo.CurrentUICulture)));
                vDir.Properties["AccessExecute"][0] = true;
    
                _Logger.Log(String.Format(CultureInfo.CurrentUICulture, VirDirCreateAccessWrite, false.ToString(CultureInfo.CurrentUICulture)));
                vDir.Properties["AccessWrite"][0] = false;
    
                _Logger.Log(String.Format(CultureInfo.CurrentUICulture, VirDirCreateAccessScript, false.ToString(CultureInfo.CurrentUICulture)));
                vDir.Properties["AccessScript"][0] = false;
    
                _Logger.Log(String.Format(CultureInfo.CurrentUICulture, VirDirCreateAuthNtlm, (!bAnonymousLogon).ToString(CultureInfo.CurrentUICulture)));
                vDir.Properties["AuthNTLM"][0] = !bAnonymousLogon;
    
                _Logger.Log(String.Format(CultureInfo.CurrentUICulture, VirDirCreateAuthAnon, bAnonymousLogon.ToString(CultureInfo.CurrentUICulture)));
                vDir.Properties["AuthAnonymous"][0] = bAnonymousLogon;
    
                _Logger.Log(String.Format(CultureInfo.CurrentUICulture, VirDirCreateDefaultDoc, true.ToString(CultureInfo.CurrentUICulture)));
                vDir.Properties["EnableDefaultDoc"][0] = true;
    
                if (!string.IsNullOrEmpty(defaultDoc))
                {
                    _Logger.Log(String.Format(CultureInfo.CurrentUICulture, VirDirCreateDefaultDoc,
                                              defaultDoc.ToString(CultureInfo.CurrentUICulture)));
                    vDir.Properties["DefaultDoc"][0] = defaultDoc + ",default.htm,default.aspx,default.asp";
                }
    
                _Logger.Log(String.Format(CultureInfo.CurrentUICulture, VirDirCreateDirBrowse, false.ToString(CultureInfo.CurrentUICulture)));
                vDir.Properties["EnableDirBrowsing"][0] = false;
    
                _Logger.Log(String.Format(CultureInfo.CurrentUICulture, VirDirCreateAppFriendlyName, directoryName));
                vDir.Properties["AppFriendlyName"][0] = directoryName;    // The name of the application
    
                if (_InstalledIISVersion >= IisVersion.Iis6)
                {
                    _Logger.Log(String.Format(CultureInfo.CurrentUICulture, VirDirCreateAppPool, directoryName));
                    vDir.Properties["AppPoolId"][0] = directoryName;
                }
    
                // Commit the changes to the directory
                vDir.CommitChanges();
    
                // Create out-of-process application
                vDir.Invoke("AppCreate", false);
    
                _Logger.Log(VirDirCreateSetUp);
    
                return vDir;
            }
            catch (Exception ex)
            {
                _Logger.Log(String.Format(CultureInfo.CurrentUICulture, VirDirCreateException, directoryName, siteId));
                _Logger.Log(ex);
                throw ;
            }
        }
    

    Also…

        /// <summary>
        /// Determines whether the directory entry exists on the specified site
        /// </summary>
        /// <param name="serverName">name of server</param>
        /// <param name="siteId">site id</param>
        /// <param name="directoryName">virtual directory name</param>
        /// <returns>the Virtual Directory, if it exists, otherwise null</returns>
        private DirectoryEntry GetVirtualDirectory(string serverName, int siteId, string directoryName)
        {
            try
            {
                DirectoryEntry root = new DirectoryEntry("IIS://" + serverName + "/W3SVC/" + siteId.ToString(CultureInfo.CurrentUICulture) + "/Root");
    
                foreach (DirectoryEntry entry in root.Children)
                {
                    if (0 == String.Compare(directoryName, entry.Name, true, CultureInfo.CurrentUICulture))
                    {
                        _Logger.Log(String.Format(CultureInfo.CurrentUICulture, VirDirFound, directoryName, serverName));
                        return entry;
                    }
                }
    
                _Logger.Log(String.Format(CultureInfo.CurrentUICulture, VirDirNotFound, directoryName, serverName));
                return null;
            }
            catch (Exception ex)
            {
                _Logger.Log(String.Format(CultureInfo.CurrentUICulture, VirDirException, directoryName, siteId, serverName));
                _Logger.Log(ex);
                throw;
            }
        }
    

    Just noticed the hungarian notation right at the top – Cringe!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created Web-Service in asp.net with c# . Now i want to pass
I have created a web service via WCF. Then I exposed it as a
I have created a web application using Visualstudio 2008 using C# on my computer.
I have created a web application with a Silverlight project embedded in it, using
I have created a web service which is saving some data into to db.
I have created a web service which takes a username and password as parameters
I have created a web service which returns some data and am trying to
I have an application built that hits a third party company's web service in
I have WCF client server application, and create msi setup projects for both projects.
I have created a component to fetch data from a web service. The web

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.