2010-07-01 122 views
1

我有一个T4Template:T4模板相对路径

<#@ 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

管理得到一个答案: string folderPath = HostingEnvironment.VirtualPathProvider.GetDirectory(“〜/ MyPagesPathj”); – 2010-07-01 14:02:51

回答

0

HostingEnvironment.VirtualPathProvider.GetDirectory(“〜/ MyPagesPathj”);