i want to set a link in VB.net dynamically to a file.
My url looks like that:
http://server/folder/folder2/file.aspx?get=param
I tried to use Request.URL but i have not found any solution to get only
http://server/folder/folder2/
without the query string and without the filename.
Please help.
You can easily get a relative file path using the
Requestinstance, then work with that, usingPathclass ought to help:It’s worth noting that
GetDirectoryNamemight transform your slashes, so you could expand the path:So, to remove redundancy, we could shorten this:
But you’ll need to check for possible exceptions.