Je dispose d'une bibliothèque de classes dans laquelle j'accède à un fichier à partir du chemin d'application en utilisant le code ci-dessous. Il ne fonctionnera pas sur azur car il ne peut pas trouver le chemin d'application. Comment le faire fonctionner azur car il fonctionne bien sur ma machine locale.Obtenir le chemin d'accès au fichier dans le projet de bibliothèque de classes asp.net sur Azure WebApp
private string GetProjectPath()
{
string SolutionName = "MyApi.sln";
//Get name of the target project which we want to test
var projectName = typeof(TerminationMatchInquiry).GetTypeInfo().Assembly.GetName().Name;
//Get currently executing test project path
var applicationBasePath = new Uri((typeof(TerminationMatchInquiry).GetTypeInfo().Assembly.CodeBase)).LocalPath;
//Find the folder which contains the solution file. We then use this information to find the
//target project which we want to test
DirectoryInfo directoryInfo = new DirectoryInfo(applicationBasePath);
do
{
var solutionFileInfo = new FileInfo(Path.Combine(directoryInfo.FullName, SolutionName));
if (solutionFileInfo.Exists)
{
return Path.GetFullPath(Path.Combine(directoryInfo.FullName, projectName));
}
directoryInfo = directoryInfo.Parent;
}
while (directoryInfo.Parent != null);
throw new Exception($"Solution root could not be located using application root {applicationBasePath}");
}
Vous voulez dire Azure WebApp? – Youngjae
Oui Azure WebApp – maxspan
Bien sûr, il ne le trouvera pas sur azur! Lorsque vous déployez votre application, vous ** ne déployez pas votre code source ** juste les artefacts binaires créés par le processus de construction/publication – Tseng