public void SaveTemplate(Template template) { if (!_lockDict.ContainsKey(template.Name)) _lockDict.Add(template.Name, new object()); lock (_lockDict[template.Name]) { var filepath = Path.Combine(HttpContext.Current.Server.MapPath("~/templates"), template.Name + ".txt"); File.WriteAllText(filepath, template.Content); } }
protected void btnSaveTemplate_Click(object sender, EventArgs e) { var template = new Template { Name=txtTemplateName.Text, Content=txtTemplate.Text }; _svc.SaveTemplate(template); BindDataList(); SelectedTabIndex = 2; }