Having & in folder name

  • Thread starter Thread starter David C
  • Start date Start date
D

David C

I am getting the following error trying to display a file in a web page.

Source: mscorlib

An unhandled exception occurred:

Message: Could not find a part of the path 'D:\Listings\Hartwig Blvd -
475\Maps & Floor Plans\GenerateThumbnail.txt'.


I assume it has something to do with the fact that one of the subfolder
names is "Maps & Floor Plans". The & is valid in a folder name so how can I
avoid this error? I am simply trying to do this and it fails on WriteFile
method:

Response.ContentType = "text/plain"

Response.WriteFile(FilePath)



David
 
David said:
I am getting the following error trying to display a file in a web
page.
Source: mscorlib

An unhandled exception occurred:

Message: Could not find a part of the path 'D:\Listings\Hartwig Blvd -
475\Maps & Floor Plans\GenerateThumbnail.txt'.


I assume it has something to do with the fact that one of the
subfolder names is "Maps & Floor Plans". The & is valid in a folder
name so how can I avoid this error? I am simply trying to do this
and it fails on WriteFile method:

Response.ContentType = "text/plain"

Response.WriteFile(FilePath)

It seems that your filepath is HTML encoded.

So, just decode it:
Response.WriteFile(Server.HtmlDecode(FilePath))
 
Back
Top