Really getting frustrated here. I've got the MapPath working and spewing
out the right path...I am able to print it out on the page with <% =
theFileMapped %>. It's just not catching on my conditional statement in the
code behind and making my panel visible. I can turn the panel on and off
manually in the <asp:label visible=> attribute, but it just doesn't work in
my code behind.
In my page:
--------------------
<ASP:PANEL ID="pnlIntro" VISIBLE="False" RUNAT="server"><SPAN
STYLE="FONT-SIZE: 10px">. </SPAN>
<A CLASS="secondNav"
HREF="/livelihoods/<% = countryCode %>/intro.pdf"
TARGET="_blank">Zoning/Profiling Intro</A><BR>
</ASP:PANEL>
In my code-behind
----------------------------
Public theFile As String
Public theFileMapped As String
Protected WithEvents pnlIntro As System.Web.UI.WebControls.Panel
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
theFile = "~/livelihoods/files/" & countryCode & "/intro.pdf"
theFileMapped = Server.MapPath(theFile)
If System.IO.File.Exists(theFileMapped) Then
pnlIntro.Visible = True
End If
End Sub
_____
DC G
"Matt Berther" <mb******@hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hello DC,
theFile = Server.MapPath("~/livelihoods/files/" & countryCode &
"/intro.pdf")
Notice the ~...
The ~ is an alias for the current virtual root. Otherwise you'd be looking
in the web applications root folder (ie: c:\inetpub\wwwroot\livelihoods)
--
Matt Berther
http://www.mattberther.com
Still no beans...here's my code...
Dim theFile As String
theFile = Server.MapPath("/livelihoods/files/" & countryCode &
"/intro.pdf")
If System.IO.File.Exists(theFile) = True Then
pnlIntro.Visible = True
End If
"Matt Berther" <mb******@hotmail.com> wrote in message
news:eH**************@TK2MSFTNGP10.phx.gbl...
Hello DC,
Since you're in a web application, try this:
string file = Server.MapPath("../folder/anotherfolder/" + aVariable +
"/adocument.pdf");
if (File.Exists(file))
{
pnlIntro.Visible=true;
}
--
Matt Berther
http://www.mattberther.com
Ok, I'm trying this but is not working. I'm using a path to and
from a webserver location...should that make a difference?
If (System.IO.File.Exists("../folder/anotherfolder/" & aVariable&
"/adocument.pdf")) Then
pnlIntro.Visible = True
End If
_____
DC G
"Rene Mansveld" <R.********@TAKETHISOUT.Spider-IT.de> wrote in
message news:eF**************@TK2MSFTNGP10.phx.gbl...
> ...or just use the File class of the System.IO namespace:
> If (System.IO.File.Exists(myFile)) Then
> myPanel.Visible = True
> End If
> --
> Hope this helps ...
> Rene Mansveld
> Spider IT - Germany (was Whitworth Software Solutions)
> www.Spider-IT.de / www.Spider-IT.net / www.Spider-IT.org /
www.Spider-IT.biz
> Please reply to the newsgroup(s) :o)
>
> "Svein Terje Gaup" <st****@broadpark.no.spam> schrieb im
> Newsbeitrag news:OG**************@TK2MSFTNGP09.phx.gbl...
>
>> Dim myFile As FileInfo = New FileInfo(myFileName)
>> If(myFile.Exists)
>> myPanel.Visible = True
>> End If
>> Sincerely
>> Svein Terje Gaup
>> "DC Gringo" <dc******@visiontechnology.net> wrote in message
>> news:e4**************@TK2MSFTNGP10.phx.gbl...
>>> How do I test for existence of a file in the file system:
>>>
>>> If FileExists(myVariable & ".pdf") = True
>>> pnlMyPanel.Visible = True
>>> End If
>>> --
>>> _____
>>> DC G