我有一个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”的相对路径,因为该路径在所有开发者机器上都不同?
答案 0 :(得分:0)
HostingEnvironment.VirtualPathProvider.GetDirectory( “〜/ MyPagesPathj”);