isnoend2001
asked on
Close a file that is not open
Hi experts
I am downloading file from the internet with freefile
FileOne = Freefile
FileTwo = Freefile
FileThree = FreeFile
After each file is downloaded then
Close #FileOne, Close #FileTwo, Close #FileThree
The connection could be interupted at any point or the form closed
Is this wrong?
on error resume next
Close #fileOne
close #filetwo
close #file Three
On error goto error handler
I realize i could write a module boolean for each file and set it to true when they get succeffuly opened and then downloaded and then selectly close them close them.
Sure be a lot easier to just close them all even if they are not open.
Bad idea?
I am downloading file from the internet with freefile
FileOne = Freefile
FileTwo = Freefile
FileThree = FreeFile
After each file is downloaded then
Close #FileOne, Close #FileTwo, Close #FileThree
The connection could be interupted at any point or the form closed
Is this wrong?
on error resume next
Close #fileOne
close #filetwo
close #file Three
On error goto error handler
I realize i could write a module boolean for each file and set it to true when they get succeffuly opened and then downloaded and then selectly close them close them.
Sure be a lot easier to just close them all even if they are not open.
Bad idea?
ASKER
I am not looking for a way to download the files. I want to intercept any error when downloading either by connection unplugged or user cancel during download. if the file is closed they can restart the download.
Just want to know if closing files that are not open is a problem
Just want to know if closing files that are not open is a problem
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Or just:
Close ' ALL OPEN FILES ARE CLOSED FOR YOU
(see my remark above)
Close ' ALL OPEN FILES ARE CLOSED FOR YOU
(see my remark above)
ASKER
Thanks guys
Thats good to know "Close" by itself will close all the open files. In this case i will have to close just the 3 files on this form. Other forms may have files open that i don't want closed. Just wanted to be sure closing a file by name that was not open would not get me later.
Thats good to know "Close" by itself will close all the open files. In this case i will have to close just the 3 files on this form. Other forms may have files open that i don't want closed. Just wanted to be sure closing a file by name that was not open would not get me later.
"URLDownloadToFileA" (ByVal pCaller As Long, _
ByVal szURL As String, _
ByVal szFileName As String, _
ByVal dwReserved As Long, _
ByVal lpfnCB As Long) As Long
Public Sub SaveURLToFile(ByVal sUrl As String, ByVal sFileName As String)
Call URLDownloadToFile(0&, sUrl, sFileName, 0, 0)
End Sub
Above code will download,open,save and close files automatically and asyncroneously