• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 178
  • Last Modified:

Run-time Error 52 When Clicking on Registered File Type to Start App

I have an application that keeps giving the following error on all machines other than my development machine when I click on my app's registered file type.

Run-time error 52: Bad file name or number

Clicking on the registered file type on the machine app was developed on works fine. However, on all other machines where program was installed it gives me the run-time error 52 when clicking on the registered file type. If I open the file within my app, I don't get the error on the other machines.

Any suggestions?
0
abnc
Asked:
abnc
  • 5
  • 5
  • 2
  • +1
1 Solution
 
vinnyd79Commented:
If you are using Command$ , have you tried compiling a message box in to test the value of Command$ on one of the other machines?
0
 
abncAuthor Commented:
I placed a msgbox to return the command$ value on the other machines and I get the full path and file name of the file that was clicked on. So that appears to be ok.
0
 
vinnyd79Commented:
Are you using FreeFile to get a file number? If so,make sure the integer is being set to a valid file #.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
vinnyd79Commented:
Actually that would cause a problem on the development machine as well.
0
 
vinnyd79Commented:
Do the files have spaces in the name? If so,try enclosing the filename in qoutes:

Chr$(34) & Command$ & Chr$(34)
0
 
abncAuthor Commented:
I am using FreeFile to get file number. If I trying the Chr$(34) that gives me a Path not found error on development machine, and on the other machines, I still get the 52 error bad file name or number.

Again, the problem only happens when I click on the registered file type. If I start the app first and then open the file, the problem does not occur.

The actual code block where the error is raised appears to be in this code below:

   Dim sTemp As String, intFileNum as Integer, intTotalCount as Integer
   intFileNum = FreeFile
   Open gstrFileName For Input As #intFileNum
   While Not EOF(intFileNum)
   Line Input #intFileNum, sTemp
   intTotalCount = intTotalCount + 1
   ReDim Preserve g_arrPhotos(intTotalCount)
   g_arrPhotos(intTotalCount - 1) = sTemp
   Wend
   Close
0
 
EDDYKTCommented:
>>when I click on the registered file type

Is it binary format?
0
 
vinnyd79Commented:
Strange, does your file type have muliple actions set? Is "open" set as the default?
0
 
abncAuthor Commented:
File being opened is a simple text file that can be opened with Notepad.
0
 
EDDYKTCommented:
do

msgbox gstrFileName

and what is this?
0
 
abncAuthor Commented:
I solved the problem, or at least it is working.

gstrFileName was my variable that would grab the Command$ value whenever Command$ has a value. However, there would be quotes (Chr(34)) surrounding the file path and name. For example, "c:\My Documents\Spain Trip.sld" and this caused the Bad File Name or Number error.

When I stripped the quotes off so that gstrFileName would be just c:\My Documents\Spain Trip.sld, with no quotes, then it worked just fine.

Make sense?
0
 
Erick37Commented:
This error can be raised if the file name has illegal characters in it:

gstrFileName = "/c:\testit.dat" '<<error 52

And of course always check if the file exists before opening it...

If FileExists(gstrFileName) Then
    'Open file
Else
    MsgBox gstrFileName & " does not exist"
End If

The FileExists function can be found here:
http://vbnet.mvps.org/index.html?code/fileapi/fileexists.htm

Good Luck!
0
 
abncAuthor Commented:
I have awarded the points to vinnyd79 since his responses got me thinking about double checking what the Command$ was returning and I noticed the problem of the quotes being passed into the variable holding the path location and filename.
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

  • 5
  • 5
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now