Solve. NET (webapplication) Install a problem where the installation path cannot be selected for deployment

Source: Internet
Author: User
Tags ini
application|web| Solution | problem (i) description
WebApplication installation path cannot be selected when the deployment is installed; Solution idea:
(1) Create a console application CreateWebDir.exe to create a Web virtual directory.
(2) Installation of the deployment of the production of Windows Application installation deployment, not WebApplication installation
Deployment. Because the Windows Application installation deployment has a selection path operation, the path selected
Save in [TARGETDIR].
(3) in the installation of deployment-"Custom Action" [Submit] under the Add custom action, select CreateWebDir.exe, its properties:
(A) Arguments = Bug2000 [TARGETDIR], that is, CreateWebDir.exe incoming two
Parameters. Bug2000 refers to the Web virtual directory; [TARGETDIR] refers to the physical directory.
(B) InstallerClass = False, set to non-ProjectInstaller class

(ii) Create a console application CreateWebDir.exe
(1) Main.cs
(2) CreateWebDir.cs See "IIS control Management--web virtual directory creation and management"
(3) INIFile.cs See "INI file operation (asp.net+c#)"

(iii) Main.cs documents

Using System;
Using System.IO;
Using System.DirectoryServices;
Using System.Runtime.InteropServices;

Namespace Createwebdir
{
<summary>
Summary description of the CLASS1.
</summary>
Class Start
{
<summary>
The main entry point for the application.
Parameter args:
ARGS[0]: Virtual path
ARGS[1]: Physical path
ARGS[2]: Server name, can not enter, default localhost
///
To run the example:
CreateWebDir.exe virdirtest D:\work
CreateWebDir.exe virdirtest D:\work Deve-server
</summary>
[STAThread]
static void Main (string[] args)
{
int i;
String IniFile;
if (args. Length > 1)
{
IniFile = args[1];
if (inifile.substring (inifile.length-1,1) = = "\")
IniFile = args[1]+ "Bug2004.ini";
Else
IniFile = args[1]+ "\\Bug2004.ini";
}
Else
IniFile = @ "C:\Bug2004.ini";

String iniFile = @ "D:\Bug2000.ini";
if (! File.exists (IniFile))
{
using (FileStream fs = File.create (IniFile))
{
Fs. Close ();
}
}

INIFile Myini = new INIFile (INIFile);

For (I=0;i<args. length;i++)
{
Myini.iniwritevalue ("WebDir", "Arg" +i.tostring (), args[i]);
}


string sserver = "localhost";
if (args. Length > 2) sserver= args[2];

Iismanager iismg = new Iismanager (sserver);
Iismg.connect ();

if (Iismg.exists (Args[0]))
{
Console.Write (args[0]+ "is exist!");
Myini.iniwritevalue ("WebDir", "Webdirexist", "true");
}
Else
{
Myini.iniwritevalue ("WebDir", "Webdirexist", "false");

Iismg.get_anonymoususer ();
string[] Anonymoususer = new string[2];
Anonymoususer[0] = Iismg.anonymoususername;
ANONYMOUSUSER[1] = Iismg.anonymoususerpass;

VirtualDirectory Newvirdir = new VirtualDirectory (args[0],args[1],anonymoususer);
if (Iismg.create (Newvirdir))
{
Console.Write (args[0]+ "Create success!");
Myini.iniwritevalue ("WebDir", "webdircreated", "true");
}
Else
{
Console.Write (args[0]+ "Create unsuccessful!");
Myini.iniwritevalue ("WebDir", "webdircreated", "false");
}
}

Iismg.close ();
}

}
}




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.