PC Review


Reply
Thread Tools Rate Thread

Check if file on intranet exists

 
 
=?Utf-8?B?bWNwaGM=?=
Guest
Posts: n/a
 
      21st Jun 2007
I need to check if a file with path "http://pmnet/113-FR-001.xls" exists
without opening it. I've tried using Dir(myPath) but I get an error 52 'Bad
file name or number'. I've also tried using the FileExists method in VB but
I'm not sure how to use it.

Thanks
 
Reply With Quote
 
 
 
 
NickHK
Guest
Posts: n/a
 
      21st Jun 2007
Maybe this:
http://vbnet.mvps.org/code/fileapi/pathfileexists.htm

NickHK

"mcphc" <(E-Mail Removed)> wrote in message
news:F848F441-D196-43D8-9388-(E-Mail Removed)...
> I need to check if a file with path "http://pmnet/113-FR-001.xls" exists
> without opening it. I've tried using Dir(myPath) but I get an error 52

'Bad
> file name or number'. I've also tried using the FileExists method in VB

but
> I'm not sure how to use it.
>
> Thanks



 
Reply With Quote
 
=?Utf-8?B?Sm9lbA==?=
Guest
Posts: n/a
 
      21st Jun 2007
http (hyper-text transfer protocol) is a transfer protocol and cannot be used
to check if a file exists. In some cases you can use File:// when generating
webpages.

the DIR command cannot be used directly to check for a file on internet.
One thing you can do is add a network drive in you window explorer. Go to
explorer and under tools "Map Netwrok drive". Assign a drive letter to
pmnet. Then you can use the drive letter and file name in the DIR command.

"mcphc" wrote:

> I need to check if a file with path "http://pmnet/113-FR-001.xls" exists
> without opening it. I've tried using Dir(myPath) but I get an error 52 'Bad
> file name or number'. I've also tried using the FileExists method in VB but
> I'm not sure how to use it.
>
> Thanks

 
Reply With Quote
 
Tim Williams
Guest
Posts: n/a
 
      22nd Jun 2007
Use xmlhttp and a "HEAD" request:

'***********************
Function HttpExists(sURL As String) As Boolean
Dim oXHTTP As Object
Set oXHTTP = CreateObject("MSXML2.XMLHTTP")
oXHTTP.Open "HEAD", sURL, False
oXHTTP.send
HttpExists = (oXHTTP.Status = 200)
End Function
'***********************

Tim


"mcphc" <(E-Mail Removed)> wrote in message
news:F848F441-D196-43D8-9388-(E-Mail Removed)...
>I need to check if a file with path "http://pmnet/113-FR-001.xls" exists
> without opening it. I've tried using Dir(myPath) but I get an error 52
> 'Bad
> file name or number'. I've also tried using the FileExists method in VB
> but
> I'm not sure how to use it.
>
> Thanks



 
Reply With Quote
 
=?Utf-8?B?bWNwaGM=?=
Guest
Posts: n/a
 
      22nd Jun 2007
That's it works perfectly! Thanks a lot.

"Tim Williams" wrote:

> Use xmlhttp and a "HEAD" request:
>
> '***********************
> Function HttpExists(sURL As String) As Boolean
> Dim oXHTTP As Object
> Set oXHTTP = CreateObject("MSXML2.XMLHTTP")
> oXHTTP.Open "HEAD", sURL, False
> oXHTTP.send
> HttpExists = (oXHTTP.Status = 200)
> End Function
> '***********************
>
> Tim
>
>
> "mcphc" <(E-Mail Removed)> wrote in message
> news:F848F441-D196-43D8-9388-(E-Mail Removed)...
> >I need to check if a file with path "http://pmnet/113-FR-001.xls" exists
> > without opening it. I've tried using Dir(myPath) but I get an error 52
> > 'Bad
> > file name or number'. I've also tried using the FileExists method in VB
> > but
> > I'm not sure how to use it.
> >
> > Thanks

>
>
>

 
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 if file exists WembleyBear Microsoft Excel Programming 3 19th May 2008 04:39 PM
Check if a file exists =?Utf-8?B?am9uZWZlcg==?= Microsoft Access Form Coding 1 12th Apr 2006 09:12 AM
Intranet app -- any way to confirm certain client file exists? KatB Microsoft ASP .NET 2 8th Jan 2004 03:48 PM
how to check if the file exists or not Mili Microsoft Excel Discussion 1 6th Nov 2003 11:45 AM
Check if file exists Newbie Microsoft Access Form Coding 3 4th Nov 2003 05:51 PM


Features
 

Advertising
 

Newsgroups
 


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