我有一个T4Template:
<#@ template language="C#" debug="True" hostspecific="True" #>
<#@ output extension=".cs" #>
<#@ assembly name="System.Web" #>
<#@ assembly name="System.Web.Mvc" #>
<#@ import namespace="System.Web.Mvc" #>
<#@ import namespace="System.IO" #>
<#@ import namespace="System.Web" #>
using System;
namespace MyNamespace.SomePages
{<#string folderPath = @"D:\_Source\TOG\aaaaaa\bbbbbbb\ccccccc\";
string[] folders = Directory.GetDirectories(folderPath);
foreach(string folderName in folders){if(!folderName.Contains(".svn")){#>
public static class <#= System.IO.Path.GetFileName(folderName)#>
{
<#foreach(string file in Directory.GetFiles(folderName)){#>
public const string <#= System.IO.Path.GetFileNameWithoutExtension(file) #> = "<#= System.IO.Path.GetFileNameWithoutExtension(file).ToString()#>";
<#}#>
}
<#}}#>}如何获取"folderPath“的相对路径,因为该路径在所有开发人员机器上都是不同的?
发布于 2010-07-08 17:15:51
HostingEnvironment.VirtualPathProvider.GetDirectory("~/MyPagesPathj");
https://stackoverflow.com/questions/3158153
复制相似问题