473,322 Members | 1,806 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,322 software developers and data experts.

spaces in file paths

The following doesn't work:

Dim photoPath As String = "R:\My Documents\My Pictures\MiscLL\"

It doesn't work if I use double quotes either. It does work if I use a
different path without spaces in it. What is the simple solution ?

--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Dec 17 '06 #1
17 6154
concatenate double quotes around it:

Dim photoPath As String = chr(34) + "R:\My Documents\My Pictures\MiscLL\" +
chr(34)
--
HTH

Éric Moreau, MCSD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
S2i web inc. (www.s2i.com)
http://emoreau.s2i.com/

"DesCF" <de***@aol.comwrote in message news:op.tkplbpvrupgxg0@descstar...
The following doesn't work:

Dim photoPath As String = "R:\My Documents\My Pictures\MiscLL\"

It doesn't work if I use double quotes either. It does work if I use a
different path without spaces in it. What is the simple solution ?

--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Dec 17 '06 #2
I'd be shocked if that didn't work. It doesn't assign that string to the
photoPath variable?

"DesCF" <de***@aol.comwrote in message news:op.tkplbpvrupgxg0@descstar...
The following doesn't work:

Dim photoPath As String = "R:\My Documents\My Pictures\MiscLL\"

It doesn't work if I use double quotes either. It does work if I use a
different path without spaces in it. What is the simple solution ?

--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Dec 17 '06 #3
"DesCF" <de***@aol.comschrieb:
>The following doesn't work:

Dim photoPath As String = "R:\My Documents\My Pictures\MiscLL\"

It doesn't work if I use double quotes either. It does work if I use a
different path without spaces in it. What is the simple solution ?
What does not work?!

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Dec 17 '06 #4
Right, the code for the entire web page is below.

If I create a directory J:\Fots and stick some photos in it, it works just
fine. If I change the directory name to J:\Fot s (i.e. insert a space
between the t and the s) it just displays the placeholders for the right
number of photos with little red X's in them.
<%@ Page Language="VB" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Collections.Generic" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<script runat="server">

''' <summary>
''' Bind photos to Repeater
''' </summary>
Sub Page_Load()
If Not Page.IsPostBack Then
Repeater1.DataSource = GetPhotos()
Repeater1.DataBind()
End If
End Sub

''' <summary>
''' Get list of photos from Photo folder
''' </summary>
Public Function GetPhotos() As List(Of String)
Dim photos As New List(Of String)()
Dim photoPath As String = "J:\Fot s\"
Dim files As String() = Directory.GetFiles(photoPath)
For Each photo As String In files
photos.Add(photoPath + Path.GetFileName(photo))
Next
Return photos
End Function

</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Show Photos</title>
</head>
<body>
<form id="form1" runat="server">
<div>

<asp:Repeater
id="Repeater1"
runat="server">
<ItemTemplate>
<asp:Image
id="Image1"
Width="200px"
ImageUrl='<%# Container.DataItem %>'
Runat="server" />
</ItemTemplate>
</asp:Repeater>

</div>
</form>
</body>
</html>

---
On Sun, 17 Dec 2006 15:00:51 -0000, DesCF <de***@aol.comwrote:
The following doesn't work:

Dim photoPath As String = "R:\My Documents\My Pictures\MiscLL\"

It doesn't work if I use double quotes either. It does work if I use a
different path without spaces in it. What is the simple solution ?


--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Dec 17 '06 #5
I tried this and I get an invalid characters in path error. Thanks for
the suggestion anyrate.
On Sun, 17 Dec 2006 16:18:30 -0000, Eric Moreau
<er*********************@videotron.cawrote:
concatenate double quotes around it:

Dim photoPath As String = chr(34) + "R:\My Documents\My
Pictures\MiscLL\" +
chr(34)



--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Dec 17 '06 #6
What are you trying to do with it; how are you trying to use it?
Post more of your code, and maybe we can help you with it.

Robin S.
------------------------------
"DesCF" <de***@aol.comwrote in message
news:op.tkptgf1aupgxg0@descstar...
I tried this and I get an invalid characters in path error. Thanks for
the suggestion anyrate.
On Sun, 17 Dec 2006 16:18:30 -0000, Eric Moreau
<er*********************@videotron.cawrote:
concatenate double quotes around it:

Dim photoPath As String = chr(34) + "R:\My Documents\My
Pictures\MiscLL\" +
chr(34)



--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Dec 17 '06 #7
Tom,

This is not in every country the same, here in Holland I have

C:\Documents and Settings\cor\Mijn documenten\Mijn afbeeldingen

I thought that Herfried had that Document and Settings in the German
language as well.

However this is as well working here.

Environment.SpecialFolder.MyPictures

I know that you knew this.

:-)

Cor

Therefore Environment.
"Tom Leylan" <tl*****@nospam.netschreef in bericht
news:Oo**************@TK2MSFTNGP03.phx.gbl...
I'd be shocked if that didn't work. It doesn't assign that string to the
photoPath variable?

"DesCF" <de***@aol.comwrote in message
news:op.tkplbpvrupgxg0@descstar...
The following doesn't work:

Dim photoPath As String = "R:\My Documents\My Pictures\MiscLL\"

It doesn't work if I use double quotes either. It does work if I use a
different path without spaces in it. What is the simple solution ?

--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

Dec 17 '06 #8
Herfried,

Sie auch, unglaublich?

:-)

Cor

"Herfried K. Wagner [MVP]" <hi***************@gmx.atschreef in bericht
news:%2****************@TK2MSFTNGP04.phx.gbl...
"DesCF" <de***@aol.comschrieb:
>>The following doesn't work:

Dim photoPath As String = "R:\My Documents\My Pictures\MiscLL\"

It doesn't work if I use double quotes either. It does work if I use a
different path without spaces in it. What is the simple solution ?

What does not work?!

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

Dec 17 '06 #9
Des

if it is your own map, than it is mostly

Environment.SpecialFolder.MyPictures

Cor

"DesCF" <de***@aol.comschreef in bericht
news:op.tkplbpvrupgxg0@descstar...
The following doesn't work:

Dim photoPath As String = "R:\My Documents\My Pictures\MiscLL\"

It doesn't work if I use double quotes either. It does work if I use a
different path without spaces in it. What is the simple solution ?

--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Dec 17 '06 #10
Cor,

"Cor Ligthert [MVP]" <no************@planet.nlschrieb:
This is not in every country the same, here in Holland I have

C:\Documents and Settings\cor\Mijn documenten\Mijn afbeeldingen

I thought that Herfried had that Document and Settings in the German
language as well.
It's "C:\Dokumente und Einstellungen\...\Eigene Dokumente\Eigene Bilder" on
my German version of Windows XP.

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

Dec 17 '06 #11
Hi Cor:

I don't believe the assignment of either string would fail in any country
:-)
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
Tom,

This is not in every country the same, here in Holland I have

C:\Documents and Settings\cor\Mijn documenten\Mijn afbeeldingen

I thought that Herfried had that Document and Settings in the German
language as well.

However this is as well working here.

Environment.SpecialFolder.MyPictures

I know that you knew this.

:-)

Cor

Therefore Environment.
"Tom Leylan" <tl*****@nospam.netschreef in bericht
news:Oo**************@TK2MSFTNGP03.phx.gbl...
>I'd be shocked if that didn't work. It doesn't assign that string to the
photoPath variable?

"DesCF" <de***@aol.comwrote in message
news:op.tkplbpvrupgxg0@descstar...
The following doesn't work:

Dim photoPath As String = "R:\My Documents\My Pictures\MiscLL\"

It doesn't work if I use double quotes either. It does work if I use a
different path without spaces in it. What is the simple solution ?

--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/


Dec 17 '06 #12
"When something doesn't seem to work correctly eliminate all the surrounding
code so you can concentrate on the one part that doesn't seem to work
correctly."

Did you try simply getting a directory and displaying the file names on your
local drive? If so did it work? I think you will find that it does work
whether or not there are spaces but you should confirm this. Now you know
that isn't the problem after all and you can spend some time finding real
problem.

BTW isn't your line: photos.Add(photoPath + Path.GetFileName(photo)) the
same as simply using the photo value? Aren't you stripping the path off and
putting it back on?

"DesCF" <de***@aol.comwrote in message news:op.tkptcogqupgxg0@descstar...
Right, the code for the entire web page is below.

If I create a directory J:\Fots and stick some photos in it, it works just
fine. If I change the directory name to J:\Fot s (i.e. insert a space
between the t and the s) it just displays the placeholders for the right
number of photos with little red X's in them.
<%@ Page Language="VB" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Collections.Generic" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<script runat="server">

''' <summary>
''' Bind photos to Repeater
''' </summary>
Sub Page_Load()
If Not Page.IsPostBack Then
Repeater1.DataSource = GetPhotos()
Repeater1.DataBind()
End If
End Sub

''' <summary>
''' Get list of photos from Photo folder
''' </summary>
Public Function GetPhotos() As List(Of String)
Dim photos As New List(Of String)()
Dim photoPath As String = "J:\Fot s\"
Dim files As String() = Directory.GetFiles(photoPath)
For Each photo As String In files
photos.Add(photoPath + Path.GetFileName(photo))
Next
Return photos
End Function

</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Show Photos</title>
</head>
<body>
<form id="form1" runat="server">
<div>

<asp:Repeater
id="Repeater1"
runat="server">
<ItemTemplate>
<asp:Image
id="Image1"
Width="200px"
ImageUrl='<%# Container.DataItem %>'
Runat="server" />
</ItemTemplate>
</asp:Repeater>

</div>
</form>
</body>
</html>

---
On Sun, 17 Dec 2006 15:00:51 -0000, DesCF <de***@aol.comwrote:
The following doesn't work:

Dim photoPath As String = "R:\My Documents\My Pictures\MiscLL\"

It doesn't work if I use double quotes either. It does work if I use a
different path without spaces in it. What is the simple solution ?


--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Dec 17 '06 #13
Tom,

I agree with you, however I saw nowhere in the answers the message to the
Environment Special folder and thought as the OP has installed in a kind of
crazy way to that R folder while also writing it in an easy way, than this
could be the problem.

It can of course as well be incorrect rights on that virtual folder as it is
often.

:-)

Cor

"Tom Leylan" <tl*****@nospam.netschreef in bericht
news:uR*************@TK2MSFTNGP03.phx.gbl...
Hi Cor:

I don't believe the assignment of either string would fail in any country
:-)
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
>Tom,

This is not in every country the same, here in Holland I have

C:\Documents and Settings\cor\Mijn documenten\Mijn afbeeldingen

I thought that Herfried had that Document and Settings in the German
language as well.

However this is as well working here.

Environment.SpecialFolder.MyPictures

I know that you knew this.

:-)

Cor

Therefore Environment.
"Tom Leylan" <tl*****@nospam.netschreef in bericht
news:Oo**************@TK2MSFTNGP03.phx.gbl...
>>I'd be shocked if that didn't work. It doesn't assign that string to
the photoPath variable?

"DesCF" <de***@aol.comwrote in message
news:op.tkplbpvrupgxg0@descstar...
The following doesn't work:

Dim photoPath As String = "R:\My Documents\My Pictures\MiscLL\"

It doesn't work if I use double quotes either. It does work if I use a
different path without spaces in it. What is the simple solution ?

--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/



Dec 18 '06 #14
Tom,

Very good answer seen all others including mine

:-)

Cor

"Tom Leylan" <tl*****@nospam.netschreef in bericht
news:e$**************@TK2MSFTNGP03.phx.gbl...
"When something doesn't seem to work correctly eliminate all the
surrounding code so you can concentrate on the one part that doesn't seem
to work correctly."

Did you try simply getting a directory and displaying the file names on
your local drive? If so did it work? I think you will find that it does
work whether or not there are spaces but you should confirm this. Now you
know that isn't the problem after all and you can spend some time finding
real problem.

BTW isn't your line: photos.Add(photoPath + Path.GetFileName(photo)) the
same as simply using the photo value? Aren't you stripping the path off
and putting it back on?

"DesCF" <de***@aol.comwrote in message
news:op.tkptcogqupgxg0@descstar...
Right, the code for the entire web page is below.

If I create a directory J:\Fots and stick some photos in it, it works just
fine. If I change the directory name to J:\Fot s (i.e. insert a space
between the t and the s) it just displays the placeholders for the right
number of photos with little red X's in them.
<%@ Page Language="VB" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Collections.Generic" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<script runat="server">

''' <summary>
''' Bind photos to Repeater
''' </summary>
Sub Page_Load()
If Not Page.IsPostBack Then
Repeater1.DataSource = GetPhotos()
Repeater1.DataBind()
End If
End Sub

''' <summary>
''' Get list of photos from Photo folder
''' </summary>
Public Function GetPhotos() As List(Of String)
Dim photos As New List(Of String)()
Dim photoPath As String = "J:\Fot s\"
Dim files As String() = Directory.GetFiles(photoPath)
For Each photo As String In files
photos.Add(photoPath + Path.GetFileName(photo))
Next
Return photos
End Function

</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Show Photos</title>
</head>
<body>
<form id="form1" runat="server">
<div>

<asp:Repeater
id="Repeater1"
runat="server">
<ItemTemplate>
<asp:Image
id="Image1"
Width="200px"
ImageUrl='<%# Container.DataItem %>'
Runat="server" />
</ItemTemplate>
</asp:Repeater>

</div>
</form>
</body>
</html>

---
On Sun, 17 Dec 2006 15:00:51 -0000, DesCF <de***@aol.comwrote:
>The following doesn't work:

Dim photoPath As String = "R:\My Documents\My Pictures\MiscLL\"

It doesn't work if I use double quotes either. It does work if I use a
different path without spaces in it. What is the simple solution ?

--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

Dec 18 '06 #15
DesCF wrote:
Right, the code for the entire web page is below.
Ahhhh, web page... URLs... no unencoded spaces allowed.
If I create a directory J:\Fots and stick some photos in it, it works
just fine. If I change the directory name to J:\Fot s (i.e. insert a
space between the t and the s) it just displays the placeholders for
the right number of photos with little red X's in them.
If you want a space in a URL, change it to "%20" or "+" for the browser. See
the UrlEncode function. A better option would be to not use spaces. Look at
the generated URLs in the resultant web page and see what the browser is
trying to ask for and also remember to look in the web server's logfile to
see what was requested and why it could not be returned.

Does that make sense?

Andrew
Dec 18 '06 #16
I have tried inserting %20 and + and I get back 'Could not find a part of
the path 'J:\Fot%20s'.' and 'Could not find a part of the path
'J:\Fot+s'.' respectively. I cannot find the UrlEncode function.

The URL Address of an empty picture placeholder is:
file:///J:/Fot%2520s/0001.jpg

I do not know where to find the web servers log file. I am using Visual
Web Developer and it creates a kind of pop-up web server on the fly.

On Mon, 18 Dec 2006 13:53:11 -0000, Andrew Morton
<ak*@in-press.co.uk.invalidwrote:
DesCF wrote:
>Right, the code for the entire web page is below.

Ahhhh, web page... URLs... no unencoded spaces allowed.
>If I create a directory J:\Fots and stick some photos in it, it works
just fine. If I change the directory name to J:\Fot s (i.e. insert a
space between the t and the s) it just displays the placeholders for
the right number of photos with little red X's in them.

If you want a space in a URL, change it to "%20" or "+" for the browser.
See
the UrlEncode function. A better option would be to not use spaces. Look
at
the generated URLs in the resultant web page and see what the browser is
trying to ask for and also remember to look in the web server's logfile
to
see what was requested and why it could not be returned.

Does that make sense?

Andrew



--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Dec 18 '06 #17
DesCF wrote:
I have tried inserting %20 and + and I get back 'Could not find a
part of the path 'J:\Fot%20s'.' and 'Could not find a part of the path
'J:\Fot+s'.' respectively.
Which program do those error messages come from?
I cannot find the UrlEncode function.
Are you saying that VWD comes without searchable help?
System.Web.HttpServerUtility.UrlEncode
>
The URL Address of an empty picture placeholder is:
file:///J:/Fot%2520s/0001.jpg
Is that when looking at the source in a browser? Because %25 is the encoding
for "%", so it looks like the URL encoding might have been done for you
already.
I do not know where to find the web servers log file. I am using
Visual Web Developer and it creates a kind of pop-up web server on
the fly.
I see from the info about VWD that "Visual Web Developer includes the
ability to create your Web applications using a Web server, FTP site, or
file share. File share-based Web sites are great for testing and don't
require you to have IIS installed on your computer, making them a great
solution on Windows XP Home Edition users." (source:
http://msdn.microsoft.com/vstudio/ex...y/default.aspx ).

Apparently you have found a case where file share-based web sites are /not/
great for testing. Could you install IIS and use that, or are you on XP
Home?

Also, you could use FileMon
(http://www.microsoft.com/technet/sys...s/filemon.mspx) or
its successor ProcessMonitor
(http://www.microsoft.com/technet/sys...ssmonitor.mspx)
to see what file the browser is requesting.

Or maybe you could just use paths and filenames without spaces?

Andrew
Dec 19 '06 #18

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

Similar topics

1
by: jnc | last post by:
Hi, I was wondering if anybody had any pointers on the following: I need to write some code which takes a list of file paths and transforms them into a treeview which shows the directory...
7
by: Travis Pupkin | last post by:
Hi, Just curious: is there a bit of ASP code you can place in the top of a document that will force all root relative image and file paths in the HTML of this doc to expand to include the full...
11
by: BoonHead, The Lost Philosopher | last post by:
I think the .NET framework is great! It's nice, clean and logical; in contradiction to the old Microsoft. It only saddens me that the new Microsoft still doesn't under stand there own...
3
by: William Starr Moake | last post by:
Is there a script to convert image file paths from absolute to just img src="imagename.jpg"? This is for an IE-based WYSIWYG editor. The doImage execCommand produces an absolute file path, which...
4
by: Enterprise Andy | last post by:
Hi, I am trying to use the Process object to launch an application (and in some cases open a file), however whenever there are any spaces in process FileName or Arguments I get an error stating...
1
by: Pete | last post by:
I know MSBUILD doesn't like spaces in file paths when used as values of elements but I cannot find anything which documents the recommended handling etc... Any and all suggestions are...
0
by: Steve | last post by:
Hi, I'm developing a web app on a Windows PC and deploying on Mac OS X Server. (Both Java 1.4.2, Tomcat 5.5.17). What's the best way to transparently different file paths on the different...
2
by: Ken Brubaker | last post by:
Does the xsd.exe command line support paths with spaces? For example the xsd.exe /o: option specifies the output file name. How can I specify an output file path that has a space? I'v tried...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.