CodeSmith应用(四):实现选择路径对话框
2006-01-12 11:24
393 查看
首先我们要添加<%@ Assembly Name="System.Design" %>命名空间。然后我们在模板中自定义一个属性,用来表示要存储的路径。其中我们使用了this.CodeTemplateInfo.DirectoryName得到当前模版所在路径作为默认路径。
private string _outputDirectory = String.Empty;
[Editor(typeof(System.Windows.Forms.Design.FolderNameEditor), typeof(System.Drawing.Design.UITypeEditor))]
[Optional]
[Category("Output")]
[Description("The directory to output the results to.")]
public string OutputDirectory
{
get
{
// default to the directory that the template is located in
if (_outputDirectory.Length == 0) return this.CodeTemplateInfo.DirectoryName + "output\\";
return _outputDirectory;
}
set
{
if (!value.EndsWith("\\")) value += "\\";
_outputDirectory = value;
}
}
这样编译运行后我们就可以看到如下效果:
![](http://images.cnblogs.com/cnblogs_com/bear-study-hard/CodeSmith应用(四)1.JPG)
单击选择路径按钮后我们就可以看到这样的窗口
![](http://images.cnblogs.com/cnblogs_com/bear-study-hard/CodeSmith应用(四)2.JPG)
选择后相应的路径值就会填入属性框。
private string _outputDirectory = String.Empty;
[Editor(typeof(System.Windows.Forms.Design.FolderNameEditor), typeof(System.Drawing.Design.UITypeEditor))]
[Optional]
[Category("Output")]
[Description("The directory to output the results to.")]
public string OutputDirectory
{
get
{
// default to the directory that the template is located in
if (_outputDirectory.Length == 0) return this.CodeTemplateInfo.DirectoryName + "output\\";
return _outputDirectory;
}
set
{
if (!value.EndsWith("\\")) value += "\\";
_outputDirectory = value;
}
}
这样编译运行后我们就可以看到如下效果:
单击选择路径按钮后我们就可以看到这样的窗口
选择后相应的路径值就会填入属性框。
相关文章推荐
- CodeSmith应用(四):实现选择路径对话框
- [导入]CodeSmith应用(四):实现选择路径对话框
- CodeSmith应用(四):实现选择路径对话框
- CodeSmith应用(四):实现选择路径对话框
- 对话框实现选择文件,并显示相应的路径
- CodeSmith应用(四):实现选择路径对话框
- 文件选择对话框、路径选择对话框的函数实现
- JS+ACTIVEX实现网页选择本地目录路径对话框
- JS+ACTIVEX实现网页选择本地目录路径对话框
- windows API实现用户选择文件路径的对话框
- 调用API实现路径选择对话框
- windows API实现用户选择文件路径的对话框
- BCB中的目录选择对话框的实现
- MFC实现选择文件夹的对话框
- C# winform 实现选择文件夹对话框
- AndroidTXT阅读器的实现(—)扫描sd卡或选择文件路径添加文件到listview及listview的多选删除
- 提供一个对话框供用户选择一个文件夹路径。
- 调用系统对话框,选择指定文件夹路径
- MFC Win32程序打开选择目录对话框并获得绝对路径
- android中实现图片的选择并通过uri获取路径