Solved

.NET File exists

Posted on 2009-04-03
2
297 Views
Last Modified: 2013-11-26
I need to do an if statement based on if a file exists...hopefully with Server.mappath

If "~/gallery/" & Request.QueryString("id") & ".swf   exists
Session("src") = "~/gallery/" & Request.QueryString("id") & ".swf  
else
Session("src") = "~/gallery/default.swf " 
0
Comment
Question by:lrbrister
2 Comments
 
LVL 18

Expert Comment

by:David Robitaille
ID: 24060333
0
 
LVL 50

Accepted Solution

by:
Ryan Chong earned 500 total points
ID: 24060395
davrob60 is right.

so, for your question... try this:

Imports System.IO


then:

'...

If File.Exists(Server.MapPath("~/gallery/" & Request.QueryString("id") & ".swf")) Then
            Session("src") = "~/gallery/" & Request.QueryString("id") & ".swf  "
        Else
            Session("src") = "~/gallery/default.swf "
        End If

'..
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
C#, asp.net MVC, sql server, LINQ 3 32
in Dot net,lastest version of MVC 3 24
ASP.NET MVC -Add authentication 2 21
MailAddress in vb 4 15
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question