Mrjefferson75 01-11-2008, 04:08 PM im trying to download a file from my server this is the code im using
when i click that button i get path not found and the
open sfile for input as #1
gets highlighted yellow how do i fix this?
Private Sub chameleonButton3_Click()
If DownloadFile("http://www.freexxxxxxxs.com/xxxxx/idish102.freedom", App.Path & "\online\idish102.freedom") Then
End If
FileName = App.Path & "\online" & "\idish102.freedom"
Sfile = FileName
sFileExtension = UCase$(Right$(Sfile, 3))
Open Sfile For Input As #1
txtEncrypted.Text = Input(LOF(1), 1)
Close #1
txtMessage.Text = fWheelDecrypt(txtEncrypted.Text, Text20)
Form2.flxBinOne.Visible = False
Sfile = App.Path & "\TEMPEP.dat"
Open Sfile For Output As #1
Print #1, txtMessage.Text
Close #1
Call ProcessHex$(Sfile, 1)
Close #1
Kill App.Path & "\TEMPEP.dat"
Kill App.Path & "\online\idish102.freedom"
Command40_Click
'Call WriteCard
End Sub
the master 01-11-2008, 04:14 PM There are a few things i would like to point out
FileName = App.Path & "\online" & "\idish102.freedom"
You should put that together so its easier to read
FileName = App.Path & "\online\idish102.freedom"
You might also want to put that line above the line that downloads the file. Then you can pass it to the downloadfile() function and you know for sure the 2 paths are the same
If DownloadFile("http://www.freexxxxxxxs.com/xxxxx/idish102.freedom", filename) Then
Look in the online folder in app.path and see if that file actually exists. Your downloadfile() function might not be creating it
Mrjefferson75 01-11-2008, 04:40 PM hi sorry if my stupidy on this im trying to fix a ap that someone else started.
the online folder should be on my server correct? and the file its trying to pull should in in that folder correct?
the master 01-11-2008, 04:45 PM Heh. Taking over other peoples code can be hard, especially if they dont comment properly.
What should be happening is DownloadFile() should grab a file from the server and put it in a folder on *your* PC. The folder is called "online" and is in the same folder as your app.
To test this open the online folder. Put a break point on "end if" and run your app. When your app pauses and "end if" is highlighted in yellow look in that folder and see if there is a file called "idish102.freedom". If not then its the DownloadFile() function thats causing the problem
Mrjefferson75 01-11-2008, 04:59 PM found the online folder its empty
the master 01-11-2008, 05:02 PM If the folder is empty when your code gets to that break point then its the DownloadFile() function that is causing the problem. Can you post that function please so we can take a look.
About your origional URL "http://www.freexxxxxxxs.com/xxxxx/idish102.freedom" Did you just blank that out or is that the actual one your using? The URL must be correct. You can paste it into IE to check if the file exists on the server or not
Mrjefferson75 01-11-2008, 05:07 PM thats the code for that button the link is good
Private Sub chameleonButton1_Click()
If DownloadFile("http://www.freedomtesters/scripts/dish102.freedom", App.Path & "\online\dish102.freedom") Then
End If
FileName = App.Path & "\online" & "\dish102.freedom"
Sfile = FileName
sFileExtension = UCase$(Right$(Sfile, 3))
Open Sfile For Input As #1
txtEncrypted.Text = Input(LOF(1), 1)
Close #1
txtMessage.Text = fWheelDecrypt(txtEncrypted.Text, Text20)
Form2.flxBinOne.Visible = False
Sfile = App.Path & "\TEMPEP.dat"
Open Sfile For Output As #1
Print #1, txtMessage.Text
Close #1
Call ProcessHex$(Sfile, 1)
Close #1
Kill App.Path & "\TEMPEP.dat"
Kill App.Path & "\online\dish102.freedom"
Command40_Click
End Sub
the master 01-11-2008, 05:14 PM Its the DownloadFile() function we need to see. I think the reason your code cant load the file is because that function isnt creating it. If the link is good then the function is probably going wrong somewhere.
While im posting ill just point out a few other things to help make your app better.
You should specify which propery of a control you are using. You have "Text20". If that is a textbox then you should put "Text20.text" like you have with the other textboxes.
When accessing files you shouldnt open any as #1. You should always generate a unique file ID. Example...
dim fileID as integer
fileID=freefile
open "c:\file.txt" for output as #fileID
close #fileID
Mrjefferson75 01-11-2008, 05:20 PM how do i find the download file function?
the master 01-11-2008, 05:24 PM You can do a search. Make sure to search the current project and look for "DownloadFile". You are looking for something that looks like "private function DownloadFile(...." or "private sub DownloadFile(...". They could be public instead. When you find it copy the whole function/sub to these forums
Mrjefferson75 01-11-2008, 05:27 PM this is all i found
Public Function DownloadFile(sSourceUrl As String, _
sLocalFile As String) As Boolean
'Download the file. BINDF_GETNEWESTVERSION forces
'the API to download from the specified source.
'Passing 0& as dwReserved causes the locally-cached
'copy to be downloaded, if available. If the API
'returns ERROR_SUCCESS (0), DownloadFile returns True.
DownloadFile = URLDownloadToFile(0&, _
sSourceUrl, _
sLocalFile, _
BINDF_GETNEWESTVERSION, _
0&) = ERROR_SUCCESS
End Function
the master 01-11-2008, 05:31 PM Thats the one. Ill setup a quick test project and see if it works
the master 01-11-2008, 05:38 PM I checked out the function and the code appears to be working correctly so i checked your script file and aparently it doesnt exist.
I opened "http://www.freedomtesters/scripts/dish102.freedom" and i got "Internet Explorer cannot display the webpage". It appears that you are either trying to load the wrong file or the file you have been using has moved on the server
Mrjefferson75 01-11-2008, 05:41 PM thats weird i use firefox and that link works i tried it in explorer and it dosent. I also checked server file scripts/dish.102
i just tried http://www.freedomtesters.com/scripts/dish102.freedom and that works in explorer this is odd
the master 01-11-2008, 05:46 PM Ive just been messing with it and i found out why. You missed ".com" out of the URL when you gave me the proper one.
Ive run that function using "http://www.freedomtesters.com/scripts/dish102.freedom" and it downloads a file fine. First check that you have ".com" in your version then put a message box in the if statement like so
If DownloadFile("http://www.freedomtesters/scripts/dish102.freedom", App.Path & "\online\dish102.freedom") Then
msgbox "The download bit works fine"
else
msgbox "There is a download problem"
End If
See what that comes up with
Mrjefferson75 01-11-2008, 06:02 PM ok i have it working i followed everything we just did on another button very similar link dont work but all files are there...
Private Sub chameleonButton3_Click()
If DownloadFile("http://www.freedomtesters.com/scripts/dishicam102.freedom", App.Path & "\online\dishicam102.freedom") Then
MsgBox "The download bit works fine"
Else
MsgBox "There is a download problem"
End If
FileName = App.Path & "\online" & "\dishicam102.freedom"
Sfile = FileName
sFileExtension = UCase$(Right$(Sfile, 3))
Open Sfile For Input As #1
txtEncrypted.Text = Input(LOF(1), 1)
Close #1
txtMessage.Text = fWheelDecrypt(txtEncrypted.Text, Text20)
Form2.flxBinOne.Visible = False
Sfile = App.Path & "\TEMPEP.dat"
Open Sfile For Output As #1
Print #1, txtMessage.Text
Close #1
Call ProcessHex$(Sfile, 1)
Close #1
Kill App.Path & "\TEMPEP.dat"
Kill App.Path & "\online\dishicam102.freedom"
Command40_Click
'Call WriteCard
End Sub
the master 01-11-2008, 06:04 PM "http://www.dishgods.tv/priv_bins/dish103-102.enc" doesnt exist. I get "The requested document was not found on this server".
If you have a problem with something like this the first thing you should do is copy the full URL into IE or firefox and see if it works
Mrjefferson75 01-11-2008, 06:09 PM sorry i posted to much code i figured it out i missed this on the button
thats how it should be
Kill App.Path & "\online\dishicam102.freedom"
i had
Kill App.Path & "\online\idish102.freedom"
the master 01-11-2008, 06:15 PM Ahh i see. I thought you meant you had this bit working and you wanted help with the other bit of code you posted.
Is it all working now?
Mrjefferson75 01-11-2008, 06:17 PM i have 5 of these to do 2 down 3 to go
Private Sub chameleonButton2_Click()
If DownloadFile("http://www.freedomtesters.com/scripts/dish103.freedom", App.Path & "\online\dish103.freedom") Then
MsgBox "The download bit works fine"
Else
MsgBox "There is a download problem"
End If
FileName = App.Path & "\online\dish103.freedom"
Sfile = FileName
sFileExtension = UCase$(Right$(Sfile, 3))
Open Sfile For Input As #1
txtEncrypted.Text = Input(LOF(1), 1)
Close #1
txtMessage.Text = fWheelDecrypt(txtEncrypted.Text, Text20)
Form2.flxBinOne.Visible = False
Sfile = App.Path & "\TEMPEP.dat"
Open Sfile For Output As #1
Print #1, txtMessage.Text
Close #1
Call ProcessHex$(Sfile, 1)
Close #1
Kill App.Path & "\TEMPEP.dat"
Kill App.Path & "\online\dish103.freedom"
Command40_Click
'Call WriteCard
End Sub
the master 01-11-2008, 06:19 PM dish103 has a capital F on freedom on the server but you have a lower case f in your app. It will only load if you have it in the correct case. The URL here should be "http://www.freedomtesters.com/scripts/dish103.Freedom"
When posting the next one please state what is wrong with it
Mrjefferson75 01-11-2008, 06:32 PM ok i figured out all 5 of them it was really odd what i did was i went to were the file was on the server and acted like i was going to rename the file but i only copied the file name and never changed anything then i went in to my form and i pasted over the file name witch was the same and then it found the link. Is it just me or is that odd?
the master 01-11-2008, 06:35 PM Nope. Its probably because they are case sensitive and when you copied it directly you copied the correct case.
Remember. To a PC "A" is completely different to "a".
It could also have been a small typo
Anyways, glad you got them working
Mrjefferson75 01-11-2008, 06:38 PM thanks for your help i have a couple more questions if you don't mind?
the master 01-11-2008, 06:39 PM I dont mind. Thats what im here for. If they arnt closely related then make sure to start a new thread though
|