Link to home
Create AccountLog in
Avatar of thenrich
thenrich

asked on

Virtual File Path

Is there a .net method to convert a file path to a virual file path?

Example:

C:/somefile.pdf
convert to:
https://www.mysite.forms/somefile.pdf

Thank you
Avatar of Scott Fell
Scott Fell
Flag of United States of America image

What do you you mean by convert?  is the file outside of the website?  If that is the case, you would use file system object http://msdn.microsoft.com/en-us/library/aa711216(v=vs.71).aspx  and copy the file to a folder inside of your webroot.
Avatar of thenrich
thenrich

ASKER

The file is inside the website.
My mistake. Convert file path to:

www.mysite.com/forms/somefile.pdf
Can you explain the situation?

There is Server.MapPath which basically does the opposite of what you want but I have not seen a function for what you need.
I want the site to serve up a file based on a file structure.

I can't explicitly embed a link as files change daily. I need the site to read the file structure. Similar to FileZilla.
Do you not know even the root folder path?

One option is to have a page which reads the file from disk and writes to client.
I am using a treeview and emulating the structure just fine. My problem is the file itself. I have a directory in which FTP users write to a modify all the time. So even though I have a root there can be multiple levels to the file itself.
I was hoping to us NavigateURL of the treeview and that's where I need the virtual path.
SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
ASKER CERTIFIED SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Codecruiser,
Yea it looks like I'll have to do some 'string-smithing' to get what I want. Was hoping for a more elegant solution.

Padas,
I don't see a solution in your posting. I'm already emulating the file structure?
why not use base href + relative path?