Path/File access error
-
Have a VB6 legacy program that has been running for years and never saw this before. It opens a text file, reads the contents and closes the file, code is:
f1 = FreeFile
Open filename For Binary As #f1 'Open the file
RawData = Input$(fileLen(filename), #f1) 'read it
Close #f1 'Close itWhen a user logs on with a non administrator account and tries to run this they get a "Path/File access error". If they log in using an administrator account it works fine. Interestingly enough, it does appear to actually read the file, but the warning is bothersome (removing the warning is not an option) I tried every combination of security on the the file permissions, enabling/disabling Modify, Read and Execute, Read, Write and so-on, the best I can do is generate a "file not found" error, not an access error. Any ideas what else to look at? Thanks in advance no-e
-
Have a VB6 legacy program that has been running for years and never saw this before. It opens a text file, reads the contents and closes the file, code is:
f1 = FreeFile
Open filename For Binary As #f1 'Open the file
RawData = Input$(fileLen(filename), #f1) 'read it
Close #f1 'Close itWhen a user logs on with a non administrator account and tries to run this they get a "Path/File access error". If they log in using an administrator account it works fine. Interestingly enough, it does appear to actually read the file, but the warning is bothersome (removing the warning is not an option) I tried every combination of security on the the file permissions, enabling/disabling Modify, Read and Execute, Read, Write and so-on, the best I can do is generate a "file not found" error, not an access error. Any ideas what else to look at? Thanks in advance no-e
If the file is in a 'my documents' directory which is not the logged in user then you will get a permissions error. You could try moving the file to a directory outside of 'my documents'
Like developing Commodore software? CBM prg Studio
-
If the file is in a 'my documents' directory which is not the logged in user then you will get a permissions error. You could try moving the file to a directory outside of 'my documents'
Like developing Commodore software? CBM prg Studio
-
Have a VB6 legacy program that has been running for years and never saw this before. It opens a text file, reads the contents and closes the file, code is:
f1 = FreeFile
Open filename For Binary As #f1 'Open the file
RawData = Input$(fileLen(filename), #f1) 'read it
Close #f1 'Close itWhen a user logs on with a non administrator account and tries to run this they get a "Path/File access error". If they log in using an administrator account it works fine. Interestingly enough, it does appear to actually read the file, but the warning is bothersome (removing the warning is not an option) I tried every combination of security on the the file permissions, enabling/disabling Modify, Read and Execute, Read, Write and so-on, the best I can do is generate a "file not found" error, not an access error. Any ideas what else to look at? Thanks in advance no-e
No-e wrote:
When a user logs on with a non administrator account and tries to run this they get a "Path/File access error". If they log in using an administrator account it works fine.
Hence, it must be something that's bound to the profile. Are you using any environment-variables? What is the path based on? Can you show an example? Any other relevant code in there that might cause errors, like reading your path from a key in the registry?
No-e wrote:
Interestingly enough, it does appear to actually read the file
It "appears"? Please verify the actual behaviour; print out the contents of the file or write it to a temp location right after reading. Does or doesn't it read the file? My guess is that it didn't.
Bastard Programmer from Hell :suss: if you can't read my code, try converting it here[^]
-
If the file is in a 'my documents' directory which is not the logged in user then you will get a permissions error. You could try moving the file to a directory outside of 'my documents'
Like developing Commodore software? CBM prg Studio
derek9999 wrote:
Like developing Commodore software? CBM prg Studio
That looks really cool and brings me back memories of programming back in the Commodore days.
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
-
Have a VB6 legacy program that has been running for years and never saw this before. It opens a text file, reads the contents and closes the file, code is:
f1 = FreeFile
Open filename For Binary As #f1 'Open the file
RawData = Input$(fileLen(filename), #f1) 'read it
Close #f1 'Close itWhen a user logs on with a non administrator account and tries to run this they get a "Path/File access error". If they log in using an administrator account it works fine. Interestingly enough, it does appear to actually read the file, but the warning is bothersome (removing the warning is not an option) I tried every combination of security on the the file permissions, enabling/disabling Modify, Read and Execute, Read, Write and so-on, the best I can do is generate a "file not found" error, not an access error. Any ideas what else to look at? Thanks in advance no-e
Since you're getting a Path/Access Violation error, you've got one of two causes. Either the path you built in "filename" is invalid, or the user that's running the code doesn't have appropriate permissions to the folderpath the file is in.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak -
Commonly, non administrator user can't access C: drive. U have to set access right for the limited user from admin.
-
No-e wrote:
When a user logs on with a non administrator account and tries to run this they get a "Path/File access error". If they log in using an administrator account it works fine.
Hence, it must be something that's bound to the profile. Are you using any environment-variables? What is the path based on? Can you show an example? Any other relevant code in there that might cause errors, like reading your path from a key in the registry?
No-e wrote:
Interestingly enough, it does appear to actually read the file
It "appears"? Please verify the actual behaviour; print out the contents of the file or write it to a temp location right after reading. Does or doesn't it read the file? My guess is that it didn't.
Bastard Programmer from Hell :suss: if you can't read my code, try converting it here[^]
No environment variables, path is read from a configuration file, fairly straight forward. Not sure about additional code, it is very simple procedure, this one reads it and converts it from hex to binary and returns it in an array (of small blocks to be shoved down a serial port in the calling routing). I could have been more clear on appears, by appears, the file must be read because the system converts it and sends it to a bunch of hardware. The operator tells me they see this happening (the system shows the file being loaded in blocks), and the hardware subsequently goes off and does its thing with this new data, which works correctly. No-e
-
derek9999 wrote:
Like developing Commodore software? CBM prg Studio
That looks really cool and brings me back memories of programming back in the Commodore days.
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
Thanks, did you give it a try?
Like developing Commodore software? CBM prg Studio
-
Thanks, did you give it a try?
Like developing Commodore software? CBM prg Studio
Yes, I've given it a try, and looks to be something to mess around with on some free time.
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus