473,396 Members | 1,590 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to convert FILE:///<PATH> to just <PATH>, using built-in classes.


I have a few file:///c:/windows/somewhere style uris that I need to convert
to the actual physical path. I am hoping there is a built in way to handle
this.

I know I can do some text replacing and get the path, at least in this case,
but I'd rather not do that if there is something that already does it more
robustly.

// Andrew
Feb 5 '08 #1
10 4403
Andrew,

You can hava a look at the uri, however I would just do
\\\
mystring = mystring.tolower.replace(file:///,"")
///

Cor
Feb 6 '08 #2
"Cor Ligthert[MVP]" <no************@planet.nlschrieb:
You can hava a look at the uri, however I would just do \\\
mystring = mystring.tolower.replace(file:///,"")
///
Hm, this won't change the path separator from "/" to "\". In addition, it
won't decode URL-encoded characters such as spaces ('%20').

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Feb 6 '08 #3
On Feb 5, 8:03 pm, Andrew Backer <awbac...@gmail.comwrote:
I have a few file:///c:/windows/somewhere style uris that I need to convert
to the actual physical path. I am hoping there is a built in way to handle
this.

I know I can do some text replacing and get the path, at least in this case,
but I'd rather not do that if there is something that already does it more
robustly.

// Andrew
If you want to get file path without "file:///" you can use substring
function as follows:
Dim a As String = "file:///c:/windows/somewhere/"
MsgBox(a.Substring(8).ToString)

which returns only "c:/windows/somewhere/"

Hope this helps.
Feb 6 '08 #4
Herfried?
">
Hm, this won't change the path separator from "/" to "\". In addition, it
won't decode URL-encoded characters such as spaces ('%20').

--
Was that the question?

Cor

Feb 7 '08 #5
"Cor Ligthert[MVP]" <no************@planet.nlschrieb:
>Hm, this won't change the path separator from "/" to "\". In addition,
it won't decode URL-encoded characters such as spaces ('%20').

Was that the question?
Yes:

| I need to convert to the actual physical path.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Feb 7 '08 #6

"Herfried K. Wagner [MVP]" <hi***************@gmx.atschreef in bericht
news:uW**************@TK2MSFTNGP04.phx.gbl...
"Cor Ligthert[MVP]" <no************@planet.nlschrieb:
>>Hm, this won't change the path separator from "/" to "\". In addition,
it won't decode URL-encoded characters such as spaces ('%20').

Was that the question?

Yes:

| I need to convert to the actual physical path.
I thought it was

I have a few file:///c:/windows/somewhere style uris that I need to convert
to the actual physical path

We have probably another OS

Cor

Feb 7 '08 #7
"Cor Ligthert[MVP]" <no************@planet.nlschrieb:
>>>Hm, this won't change the path separator from "/" to "\". In addition,
it won't decode URL-encoded characters such as spaces ('%20').

Was that the question?

Yes:

| I need to convert to the actual physical path.
I thought it was

I have a few file:///c:/windows/somewhere style uris that I need to
convert
to the actual physical path

Yes, but 'c:/windows/some%20directory' is not the local path described by
the URI 'file:///c:/windows/some%20directory'. Instead, it's
'c:\windows\some directory'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Feb 8 '08 #8

"Herfried K. Wagner [MVP]" <hi***************@gmx.atschreef in bericht
news:ON**************@TK2MSFTNGP06.phx.gbl...
"Cor Ligthert[MVP]" <no************@planet.nlschrieb:
>>
I thought it was

I have a few file:///c:/windows/somewhere style uris that I need to
convert
to the actual physical path


Yes, but 'c:/windows/some%20directory' is not the local path described by
the URI 'file:///c:/windows/some%20directory'. Instead, it's
'c:\windows\some directory'.
Why do you think that I wrote:
"You can always have a look at the Uri"
Do you think that I did not know what you wrote?
(Sounds agresive but is not meant as that, just smiling).

Cor

Feb 8 '08 #9
How about:
new Uri(myUriFilePath).LocalPath
*** Sent via Developersdex http://www.developersdex.com ***
Mar 13 '08 #10
You can create a System.Uri object from your your string. Uri object
has a LocalPath property that returns a system specific path. It
appears to do the trick.

*** Sent via Developersdex http://www.developersdex.com ***
Jun 27 '08 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Haim Ashkenazi | last post by:
Hi I have to write a function that returns a list of all directories under <PATH> (should work on linux and windows). it should be easy to write a loop that goes through every directory... and...
6
by: Tim | last post by:
I am in the process of moving a site from one hosting company to another. This site is fairly large, with hundreds of asp files, each with multiple "include" statements. The new host has a...
4
by: Carsten Kraft | last post by:
Hello Newsgroup, I am searching for function which returns me filename from a string that has the file + filepath. ( string sFile = "C:\DIR\SUBDIR\TEST.XML" => TEST.XML) Is there a...
10
by: Dustin Wilson | last post by:
I'm looking for a quick function that will give me just the path for a file. For example if I have the string "C:\Temp\MyFile.txt", I want to just return just the string "C:\Temp\". How is this...
2
by: Hrvoje Voda | last post by:
How to check if a file path is correct? Hrcko
5
by: kiran | last post by:
hi, i just wanted to retrieve path of a file residing on local client system using javascript
1
Fary4u
by: Fary4u | last post by:
Hi Guys i'm trying to upload a file, i've tried 3 different methods but still not work out i don't know how to over come this problem hidden file value, multiple form or popup uploading. 1-...
0
Fary4u
by: Fary4u | last post by:
Hi Guys i'm trying to upload a file, i've tried 3 different methods but still not work out i don't know how to over come this problem hidden file value, multiple form or popup uploading. 1-...
8
by: yguan08 | last post by:
I have trouble of obtaining the file size of a file because the fullpath exceeds 255 characters. I get this message with os.path.getsize(fullpath). fullpath = r"\\LOSSSFS002\NWE_TECHNICAL\05....
1
by: Stefan Pascal | last post by:
Hello. I have a very strange problem on my system with running C# applications from a longer than usual (>127 chars) path. I was able to reproduce the following 2 cases: 1. Socket s = new...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.