开发者

How do i copy files to virtual path at run time

开发者 https://www.devze.com 2023-04-11 04:33 出处:网络
I am loading a user control dynamically like below User开发者_Python百科Control objUserControl = (UserControl)this.LoadControl(\"~/UserControls/ucProfileViewDefault.ascx\");

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"));
0

精彩评论

暂无评论...
验证码 换一张
取 消