1
J'ai un T4Template:modèle T4 chemin relatif
<#@ 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()#>";
<#}#>
}
<#}}#>}
comment puis-je obtenir un chemin relatif pour « folderPath » comme ce chemin est différent sur toutes les machines de développeurs?
Géré pour obtenir une réponse: string folderPath = HostingEnvironment.VirtualPathProvider.GetDirectory ("~/MyPagesPathj"); –