Re: File not found

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Melvin wrote:
"Melvin" <marvwade@xxxxxxxxxxxxxxx> wrote in message news:%23ePvKCh7JHA.1416@xxxxxxxxxxxxxxxxxxxxxxx
"argusy" <argusy@xxxxxxxxxxxxxxx> wrote in message news:024448df$0$20662$c3e8da3@xxxxxxxxxxxxxxxxxxxx
Melvin wrote:
This is a follow-up to a previous post suggesting I use an API in downloading prices from the internet. I think this routine can be modified but I am hung up on the portion of the routine where is tries to open the sLocal file. If I run it as is I get Runtime error 75. I am not sure if the local file has to be created prior to running the process. If so, it the name of the folder actually "c:\deleteme.htm"? I have created a file with that name and extension in c: but when I try to run the routine I still get the file/path access error.

A copy of the routines is:

Option Explicit

Private Declare Function URLDownloadToFile Lib "urlmon" _
Alias "URLDownloadToFileA" _
(ByVal pCaller As Long, _
ByVal szURL As String, _
ByVal szFileName As String, _
ByVal dwReserved As Long, _
ByVal lpfnCB As Long) As Long

Private Const ERROR_SUCCESS As Long = 0
Private Const BINDF_GETNEWESTVERSION As Long = &H10
Private Const INTERNET_FLAG_RELOAD As Long = &H80000000

Private Sub Command1_Click()
Dim sSourceUrl As String
Dim sLocalFile As String
Dim hfile As Long

sSourceUrl = "http://vbnet.mvps.org/code/faq/fileloadtext.htm";
sLocalFile = "c:\deleteme.htm"

If DownloadFile(sSourceUrl, sLocalFile) Then
hfile = FreeFile
Open sLocalFile For Input As #hfile
Debug.Print Input$(LOF(hfile), hfile)
Close #hfile
End If
End Sub

Public Function DownloadFile(sSourceUrl As String, sLocalFile As String) As Boolean
DownloadFile = URLDownloadToFile(0&, sSourceUrl, sLocalFile, _
BINDF_GETNEWESTVERSION, 0&) = ERROR_SUCCESS
End Function

Any assistance would be appreciated.

Mel

Hi, Mel

I dropped that code into a new project and it worked.

It didn't matter if the local file existed or not - your code created the local file or overwrote it.
Graham


Graham, now I am really confused. Since you found it to work I copied the exact code from my original message into a new project and I still get the error message "Run-time error '75': Path/File access error". I was careful to remove any file named "deleteme.htm" from drive C and also changed the source location to drive "J:\" sameerror results. I changed the file name for drives C and I - same results. I even moved the whole process to a different computer. Same results.

How can this be?

Mel


Correction.. The process DID work on another computer. Gad!!

Mel


And, as Nobody pointed out, administrator permissions come into play with Vista, and recommend his usage of ENVIRON to set your target file
I didn't think of that, as I have administrator privileges on an XP system

Graham
.



Relevant Pages

  • Re: File not found
    ... I think this routine can be modified but I am hung up on the portion of the routine where is tries to open the sLocal file. ... ByVal szFileName As String, _ ... Dim hfile As Long ... If DownloadFile(sSourceUrl, sLocalFile) Then ...
    (microsoft.public.vb.general.discussion)
  • Re: File not found
    ... I think this routine can be modified but I am hung up on the portion of the routine where is tries to open the sLocal file. ... ByVal szFileName As String, _ ... Dim hfile As Long ... If DownloadFile(sSourceUrl, sLocalFile) Then ...
    (microsoft.public.vb.general.discussion)
  • Re: File not found
    ... I think this routine can be modified but I am hung up on the portion of the routine where is tries to open the sLocal file. ... ByVal szFileName As String, _ ... Dim hfile As Long ... If DownloadFile(sSourceUrl, sLocalFile) Then ...
    (microsoft.public.vb.general.discussion)
  • File not found
    ... I think this routine can be modified but I am hung up on the portion of the routine where is tries to open the sLocal file. ... ByVal szFileName As String, _ ... Dim hfile As Long ... If DownloadFile(sSourceUrl, sLocalFile) Then ...
    (microsoft.public.vb.general.discussion)
  • Re: File not found
    ... I think this routine can be modified but I am hung up on the portion of the routine where is tries to open the sLocal file. ... ByVal szFileName As String, _ ... Dim hfile As Long ... If DownloadFile(sSourceUrl, sLocalFile) Then ...
    (microsoft.public.vb.general.discussion)