在大家的帮助下,终于写成了创建输出目录的模板,再次还是感谢所有的热心的朋友。现在还是回到我们的正题来。要创建输入模板主要是写程序集的引用和命名空间的引用。完整的模版代码如下: <%@ CodeTemplate Language="C#" TargetLanguage="Text" Debug="True" Description="Template description here." %><%@ Assembly Name="SchemaExplorer" %><%@ Assembly Name="CodeSmith.CustomProperties" %> <%@ Assembly Name="System.Design" %><%@ Import Namespace="System.IO" %><%@ Import Namespace="SchemaExplorer" %><% if(!Directory.Exists(OutputDirectory)) Directory.CreateDirectory(OutputDirectory); %><script runat="template"> Output#region Output private string _outputDirectory = String.Empty; [Editor(typeof(System.Windows.Forms.Design.FolderNameEditor), typeof(System.Drawing.Design.UITypeEditor))] [CodeTemplateProperty(CodeTemplatePropertyOption.Optional)] [Category("General")] [Description("The directory to output the results to.")] [DefaultValue("")] public string OutputDirectory { get { if (_outputDirectory.Length == 0) { return @"F:\FurturesSms"; } else { return _outputDirectory; } } set { if (value.EndsWith("\\")) value = value.Substring(0, value.Length - 1); _outputDirectory = value; } } #endregion</script>这里需要说下,主要是以上的引用一个都不能少,我最开始就是因为引用得不够,才困惑了很久。 转载于:https://www.cnblogs.com/gjahead/archive/2007/05/16/749274.html