?
Solved

.NET File exists

Posted on 2009-04-03
2
Medium Priority
?
306 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 18

Expert Comment

by:David Robitaille
ID: 24060333
0
 
LVL 53

Accepted Solution

by:
Ryan Chong earned 2000 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

649 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