The Artima Developer Community
Sponsored Link

.NET Buzz Forum
ASP.NET: URL aus lokalem Pfad generieren

0 replies.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a flat view of this topic  Flat View
Previous Topic   Next Topic
Threaded View: This topic has 0 replies on 1 page
-

Posts: 1524
Nickname: nitronic
Registered: Jul, 2006

Norbert Eder works as a software architect.
ASP.NET: URL aus lokalem Pfad generieren Posted: Aug 22, 2007 2:40 AM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by -.
Original Post: ASP.NET: URL aus lokalem Pfad generieren
Feed Title: Norbert Eder - Living .NET
Feed URL: http://feeds.feedburner.com/NorbertEder-Livingnet
Feed Description: Copyright (c)2005, 2006 by Norbert Eder
Latest .NET Buzz Posts
Latest .NET Buzz Posts by -
Latest Posts From Norbert Eder - Living .NET

Mit Server.MapPath kann sehr einfach der lokale Pfad zu einer Datei generiert werden. In manchen Fällen ist jedoch der umgekehrte Weg notwendig: Aus einem vorhanden Pfad soll eine URL erstellt werden. Nachfolgendes Code-Snippet zeigt, wie dies geht:
private String ReverseMapPath(String PhysicalFilePath)
{
    String AppPath = HttpContext.Current.Server.MapPath("~");
    String url = String.Format
        ("~{0}", 
         PhysicalFilePath.Replace(AppPath, "").Replace("", "/"));
    return url;
}

Read: ASP.NET: URL aus lokalem Pfad generieren


Topic: MSDN a la Kay Previous Topic   Next Topic Topic: Geiler RAM! Jawohl!

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use