Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0How to convert physical absolute full filename to url?How to convert physical absolute full filename to url?
Previous
 
Next
New Post
7/20/2008 3:57 AM
 

Hi experts,

I am developing a DNN Module which stores some files to a certain physical store (DotNetNuke.Common.Globals.HostMapPath).

The result is a full filename like C:\Programme\DNN\Portals\_default\\MyFolder\MyFile.txt

How can I convert this absolute file name to a link?

I have recherched in google but Server.MapPath and ResolveUrl seems not to be the correct API calls for that, because the DNN Module (UserControl) can be located in any localtion of the website (and in my understanding this functions use the current page for resolving or mapping an url or paht, aren't they?)

Many thanks in advance.

LG
George

 

 
New Post
7/20/2008 3:09 PM
 

Hi experts,

meantime I have found following solution.

I am using the Request.PhysicalApplicationPath Propery to cut the physical path to the virtual path and replace back slash to slash

StringBuilder sb = new StringBuilder();

String pathstring = "C:\\Dokumente und Einstellungen\\Georg\\Eigene Dateien\\Visual Studio 2008\\Projects\\Beispiele\\VirtualPathHelperClass\\Portal\\_default\\Backup\\Test.txt";

string physicalpath = Request.PhysicalApplicationPath;

string FilePath = "";

if (pathstring.StartsWith(physicalpath))

    FilePath = pathstring.Remove(0, physicalpath.Length-1);

FilePath = FilePath.Replace("\\","/");

 

sb.Append("<a href =\"" + FilePath + "\">Testlink</a><br>");

Response.Write(sb.ToString());

 

If you know a better one (e.g. build in function) pleas let me know!

 

Best regards

George

 

 

 
New Post
7/20/2008 9:44 PM
 

There are a couple of inbuilt functions that allow you to get the physical path as well as the URL link that are built into the core. I don't remember them off the top of my head but I believe they're in the common Utilities class. I don't have my code machine in front of me but I believe there is Common.Globals.HostMapPath and PortalSettings.HomeDirectoryMapPath. There should be a FileSystemsUtil class that you can also use and might have some of the stuff you're looking for...
Sanjay

 


AcuitiDP - Oracle Data Provider for DotNetNuke
 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0How to convert physical absolute full filename to url?How to convert physical absolute full filename to url?


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out