Advertisements

Dynamically Changing style,file in Asp.net using C#



 

protected void btnSaveStyle_Click(object sender, EventArgs e)
{
string sourcePath = Server.MapPath(“~/css/” + ddlStylelist.SelectedValue.ToString());
string targetPath = Server.MapPath(“~/css”);
if (!Directory.Exists(targetPath))
{
Directory.CreateDirectory(targetPath);
}
foreach (var srcPath in Directory.GetFiles(sourcePath))
{
//Copy the file from sourcepath and place into mentioned target path,
//Overwrite the file if same file is exist in target path
File.Copy(srcPath, srcPath.Replace(sourcePath, targetPath), true);
}
lblMsg.Text = “Theme changed Successfully…!”;
}

 


Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: