How do i copy files to virtual path at run time
I am loading a user control dynamically like below
User开发者_Python百科Control objUserControl = (UserControl)this.LoadControl("~/UserControls/ucProfileViewDefault.ascx");
Now I have another user control file ucProfileViewSMSIS.ascx which is located in some other location . I need to copy this file to my virtual path at run time and then load it like below
UserControl objUserControl = (UserControl)this.LoadControl("~/UserControls/ucProfileViewSMSIS.ascx");
How do i do this ?
Server.MapPath
and Page.ResloveUrl
will get you the location, then you can move it and load:
var path = Server.MapPath(Page.ResolveUrl("~/UserControls/ucProfileViewSMSIS.ascx"));
精彩评论