PC Review


Reply
Thread Tools Rate Thread

Check for file existence within own site

 
 
John
Guest
Posts: n/a
 
      29th Jan 2008
Hi there,

I have a method in a code behind class that, given a string, checks to see
if the respective file exists within the same site. I'm using this:

System.IO.File.Exists(strFilePath)

....but is that the right way to check for a file in your own site and if so
does strFilePath need to be in a particular format?

Thanks in advance.

John


 
Reply With Quote
 
 
 
 
Kevin Spencer
Guest
Posts: n/a
 
      29th Jan 2008
If you're looking for a file that should be on the same machine, and your
app has the proper file system permissions, that is a perfectly fine way to
check for its existence. Otherwise, you can create an HttpRequest, and see
if you get a 404 (Not Found) Response code.

--
HTH,

Kevin Spencer
Chicken Salad Surgeon
Microsoft MVP

"John" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Hi there,
>
> I have a method in a code behind class that, given a string, checks to see
> if the respective file exists within the same site. I'm using this:
>
> System.IO.File.Exists(strFilePath)
>
> ...but is that the right way to check for a file in your own site and if
> so does strFilePath need to be in a particular format?
>
> Thanks in advance.
>
> John
>
>



 
Reply With Quote
 
John
Guest
Posts: n/a
 
      29th Jan 2008
Hello Kevin,

Thanks for your reply. When I say file, I mean I'm checking the existance
of another page (MyPage.aspx) within the site. Does that change things?

Thanks

John

"Kevin Spencer" <unclechutney@localhost> wrote in message
news:uU%(E-Mail Removed)...
> If you're looking for a file that should be on the same machine, and your
> app has the proper file system permissions, that is a perfectly fine way
> to check for its existence. Otherwise, you can create an HttpRequest, and
> see if you get a 404 (Not Found) Response code.
>
> --
> HTH,
>
> Kevin Spencer
> Chicken Salad Surgeon
> Microsoft MVP
>
> "John" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>> Hi there,
>>
>> I have a method in a code behind class that, given a string, checks to
>> see if the respective file exists within the same site. I'm using this:
>>
>> System.IO.File.Exists(strFilePath)
>>
>> ...but is that the right way to check for a file in your own site and if
>> so does strFilePath need to be in a particular format?
>>
>> Thanks in advance.
>>
>> John
>>
>>

>
>



 
Reply With Quote
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      30th Jan 2008
Hi John,

As you mentioned, the code is used in page codebehind. So that checking
page is in the same web application of other pages you want to check(or at
least on the same server machine)? If so, I agree that the System.IO
components are the proper approach here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.


--------------------
>From: "John" <(E-Mail Removed)>
>References: <#(E-Mail Removed)>

<uU#(E-Mail Removed)>
>Subject: Re: Check for file existence within own site
>Date: Tue, 29 Jan 2008 18:46:34 -0000


>
>Hello Kevin,
>
>Thanks for your reply. When I say file, I mean I'm checking the existance
>of another page (MyPage.aspx) within the site. Does that change things?
>
>Thanks
>
>John
>
>"Kevin Spencer" <unclechutney@localhost> wrote in message
>news:uU%(E-Mail Removed)...
>> If you're looking for a file that should be on the same machine, and

your
>> app has the proper file system permissions, that is a perfectly fine way
>> to check for its existence. Otherwise, you can create an HttpRequest,

and
>> see if you get a 404 (Not Found) Response code.
>>
>> --
>> HTH,
>>
>> Kevin Spencer
>> Chicken Salad Surgeon
>> Microsoft MVP
>>
>> "John" <(E-Mail Removed)> wrote in message
>> news:%(E-Mail Removed)...
>>> Hi there,
>>>
>>> I have a method in a code behind class that, given a string, checks to
>>> see if the respective file exists within the same site. I'm using this:
>>>
>>> System.IO.File.Exists(strFilePath)
>>>
>>> ...but is that the right way to check for a file in your own site and

if
>>> so does strFilePath need to be in a particular format?
>>>
>>> Thanks in advance.
>>>
>>> John
>>>
>>>

>>
>>

>
>
>


 
Reply With Quote
 
John
Guest
Posts: n/a
 
      30th Jan 2008
Great. Thanks very much for the confirmation Steven.

Best regards

John

"Steven Cheng[MSFT]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi John,
>
> As you mentioned, the code is used in page codebehind. So that checking
> page is in the same web application of other pages you want to check(or at
> least on the same server machine)? If so, I agree that the System.IO
> components are the proper approach here.
>
> Sincerely,
>
> Steven Cheng
>
> Microsoft MSDN Online Support Lead
>
>
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>
>
> --------------------
>>From: "John" <(E-Mail Removed)>
>>References: <#(E-Mail Removed)>

> <uU#(E-Mail Removed)>
>>Subject: Re: Check for file existence within own site
>>Date: Tue, 29 Jan 2008 18:46:34 -0000

>
>>
>>Hello Kevin,
>>
>>Thanks for your reply. When I say file, I mean I'm checking the existance
>>of another page (MyPage.aspx) within the site. Does that change things?
>>
>>Thanks
>>
>>John
>>
>>"Kevin Spencer" <unclechutney@localhost> wrote in message
>>news:uU%(E-Mail Removed)...
>>> If you're looking for a file that should be on the same machine, and

> your
>>> app has the proper file system permissions, that is a perfectly fine way
>>> to check for its existence. Otherwise, you can create an HttpRequest,

> and
>>> see if you get a 404 (Not Found) Response code.
>>>
>>> --
>>> HTH,
>>>
>>> Kevin Spencer
>>> Chicken Salad Surgeon
>>> Microsoft MVP
>>>
>>> "John" <(E-Mail Removed)> wrote in message
>>> news:%(E-Mail Removed)...
>>>> Hi there,
>>>>
>>>> I have a method in a code behind class that, given a string, checks to
>>>> see if the respective file exists within the same site. I'm using
>>>> this:
>>>>
>>>> System.IO.File.Exists(strFilePath)
>>>>
>>>> ...but is that the right way to check for a file in your own site and

> if
>>>> so does strFilePath need to be in a particular format?
>>>>
>>>> Thanks in advance.
>>>>
>>>> John
>>>>
>>>>
>>>
>>>

>>
>>
>>

>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Check existence of file if file name has a space in it. mc Microsoft Excel Programming 3 30th Sep 2008 07:39 PM
Check File Name Existence in Array =?Utf-8?B?S2lyayBQLg==?= Microsoft Excel Programming 2 6th Jun 2007 10:10 PM
I need to check for existence of a file on our website in "images"... trint Microsoft C# .NET 3 23rd Apr 2007 05:24 PM
Check for existence of a file =?Utf-8?B?REtT?= Microsoft Excel Programming 4 9th Apr 2007 08:46 PM
Check File Existence =?Utf-8?B?Q2F0YWxpbg==?= Microsoft Excel Programming 5 10th May 2006 10:20 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:25 AM.