|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
NTFS File Access in VB6the following routine: Open path For Binary Access Read As 1 Text1.Text = StrConv(InputB$(LOF(1), 1), vbUnicode) Close #1 he(and the app) gets: Runtime Error: Bad file name or number (Error 52) I think this can be handled as: On Error GoTo er ..... ..... er: if Err.Number=52 Then etc. Are there any better way?... -- playwin Hi,
I think what you have just there is fine. Why change it? If you need to determine explicitly whether or not the security context in which your application is running has permissions to read a particular file, there are probably APIs you could use somewhere. But... I doubt it's worth the effort. Robert Show quoteHide quote "playwin" <dicussi***@microsoft.com> wrote in message news:%23BtF8tGRGHA.3916@TK2MSFTNGP11.phx.gbl... > If user X tries to open foo.txt(path), which he does not have access, with > the following routine: > > Open path For Binary Access Read As 1 > Text1.Text = StrConv(InputB$(LOF(1), 1), vbUnicode) > Close #1 > > he(and the app) gets: > > Runtime Error: Bad file name or number (Error 52) > > > I think this can be handled as: > > On Error GoTo er > .... > .... > er: > if Err.Number=52 Then etc. > > Are there any better way?... > -- > playwin > Hi,
Thanks, yes I think same there is no need to involve API(if any). -- Show quoteHide quoteplaywin "Robert Ellis" <robe_2k5.n0s***@hotmail.co.uk> wrote in message news:ulP6FQHRGHA.1608@TK2MSFTNGP09.phx.gbl... > Hi, > > I think what you have just there is fine. Why change it? > > If you need to determine explicitly whether or not the security context > in which your application is running has permissions to read a particular > file, there are probably APIs you could use somewhere. But... I doubt it's > worth the effort. > > Robert > > > > "playwin" <dicussi***@microsoft.com> wrote in message > news:%23BtF8tGRGHA.3916@TK2MSFTNGP11.phx.gbl... >> If user X tries to open foo.txt(path), which he does not have access, >> with the following routine: >> >> Open path For Binary Access Read As 1 >> Text1.Text = StrConv(InputB$(LOF(1), 1), vbUnicode) >> Close #1 >> >> he(and the app) gets: >> >> Runtime Error: Bad file name or number (Error 52) >> >> >> I think this can be handled as: >> >> On Error GoTo er >> .... >> .... >> er: >> if Err.Number=52 Then etc. >> >> Are there any better way?... >> -- >> playwin >> > >
Show quote
Hide quote
"playwin" <dicussi***@microsoft.com> wrote First step, isolate the command that gives you the error.> If user X tries to open foo.txt(path), which he does not have access, with > the following routine: > > Open path For Binary Access Read As 1 > Text1.Text = StrConv(InputB$(LOF(1), 1), vbUnicode) > Close #1 > > he(and the app) gets: > > Runtime Error: Bad file name or number (Error 52) ......... > Are there any better way?... If its the Open command, be sure the path exists, and read about (and use) FreeFile to get an appropreate file handle. If it errors on the InputB line, break that up into individual steps (read to an array, then convert the array) until you can determine exactly which command is giving you problems. After doing that, if you can't fix the error yourself from there, post back with the new information - Which line, which command which error, etc... LFS
Show quote
Hide quote
"Larry Serflaten" <serfla***@usinternet.com> wrote in message Hi Larry,news:uAahlQHRGHA.1688@TK2MSFTNGP11.phx.gbl... > > "playwin" <dicussi***@microsoft.com> wrote >> If user X tries to open foo.txt(path), which he does not have access, >> with >> the following routine: >> >> Open path For Binary Access Read As 1 >> Text1.Text = StrConv(InputB$(LOF(1), 1), vbUnicode) >> Close #1 >> >> he(and the app) gets: >> >> Runtime Error: Bad file name or number (Error 52) > ........ >> Are there any better way?... > > > First step, isolate the command that gives you the error. > > If its the Open command, be sure the path exists, and > read about (and use) FreeFile to get an appropreate file > handle. > > If it errors on the InputB line, break that up into individual > steps (read to an array, then convert the array) until you can > determine exactly which command is giving you problems. > > After doing that, if you can't fix the error yourself from there, > post back with the new information - Which line, which command > which error, etc... > > LFS > I think you misunderstood a bit, no there is no coding error, I just wanted to know are there any better ways to handle file >security access.< -- playwin
VB.NET or C++.NET or C#
Password Change how to convert string to date? Text to Speech TransparentBlt and Autoredraw issues (refresh isnt solving it) Picturebox fit newbe question Sub or Function is not defined write to disk and permissions Control similar to MS Access List Box Code for stored procedures |
|||||||||||||||||||||||