Check for file existence within own site
Check for file existence within own site
am 29.01.2008 12:59:09 von John
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
Re: Check for file existence within own site
am 29.01.2008 13:40:06 von Kevin Spencer
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" wrote in message
news:%23JZzd5mYIHA.4476@TK2MSFTNGP06.phx.gbl...
> 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
>
>
Re: Check for file existence within own site
am 29.01.2008 19:46:34 von John
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" wrote in message
news:uU%23UVQnYIHA.1376@TK2MSFTNGP02.phx.gbl...
> 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" wrote in message
> news:%23JZzd5mYIHA.4476@TK2MSFTNGP06.phx.gbl...
>> 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
>>
>>
>
>
Re: Check for file existence within own site
am 30.01.2008 03:58:53 von stcheng
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"
>References: <#JZzd5mYIHA.4476@TK2MSFTNGP06.phx.gbl>
>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" wrote in message
>news:uU%23UVQnYIHA.1376@TK2MSFTNGP02.phx.gbl...
>> 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" wrote in message
>> news:%23JZzd5mYIHA.4476@TK2MSFTNGP06.phx.gbl...
>>> 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
>>>
>>>
>>
>>
>
>
>
Re: Check for file existence within own site
am 30.01.2008 07:42:49 von John
Great. Thanks very much for the confirmation Steven.
Best regards
John
"Steven Cheng[MSFT]" wrote in message
news:taudUwuYIHA.4200@TK2MSFTNGHUB02.phx.gbl...
> 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"
>>References: <#JZzd5mYIHA.4476@TK2MSFTNGP06.phx.gbl>
>
>>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" wrote in message
>>news:uU%23UVQnYIHA.1376@TK2MSFTNGP02.phx.gbl...
>>> 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" wrote in message
>>> news:%23JZzd5mYIHA.4476@TK2MSFTNGP06.phx.gbl...
>>>> 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
>>>>
>>>>
>>>
>>>
>>
>>
>>
>