CopyProject Method
Collapse the table of content
Expand the table of content

VSProject.CopyProject Method (String, String, prjCopyProjectOption, String, String)

 

Copies some or all of a Web project to a new location.

Namespace:   VSLangProj
Assembly:  VSLangProj (in VSLangProj.dll)

void CopyProject(
	string bstrDestFolder,
	string bstrDestUNCPath,
	prjCopyProjectOption copyProjectOption,
	string bstrUsername,
	string bstrPassword
)

Parameters

bstrDestFolder
Type: System.String

Required. The destination folder for the new project. The folder is created if it does not exist. This string takes the form "http://ServerName/CopyName/".

bstrDestUNCPath
Type: System.String

Required. The UNC path for file-sharing if the project to be copied is using file-share access. Use the empty string if the project is using FrontPage Server Extensions access.

copyProjectOption
Type: VSLangProj.prjCopyProjectOption

Required. A prjCopyProjectOption value that determines which project files are copied — all the files, all the project files, or only the files needed to run the application.

bstrUsername
Type: System.String

Required. The user's network login ID.

bstrPassword
Type: System.String

Required. The user's password. 

This method, used to copy Web projects, provides more functionality than a simple xcopy of the project files, but less functionality than deployment. The CopyProject method will make the appropriate changes to IIS and the project folder on the Web server, so that development can continue as usual on the project. Deployment provides more features for setting up a Web, including creating databases and message queues.

This method copies only Web projects. Web projects are projects created from the ASP.NET Web application, XML Web Service, and Empty Web Project templates in the New Project dialog box. If the project is a local project, an exception is raised.

If the destination folders or files already exist, they will be overwritten.

[Visual Basic]

' Macro editor
' Copies the first project in the solution.
' This procedure could fail if the first project is not a Visual Basic
' or Visual C# project, or if the project is not a Web application.
Imports VSLangProj
Public Sub CopyWeb()
   Try
      Dim proj As VSLangProj.VSProject = _
         CType(DTE.Solution.Projects.Item(1).Object, VSLangProj.VSProject)
      proj.CopyProject("http://Localhost/Copy_of_Project", "", _
         prjCopyProjectOption.prjRunFiles, "", "")
   Catch ex As System.Exception
      MsgBox("Cannot copy Web project.")
   End Try
End Sub
Return to top
Show:
© 2016 Microsoft