0

我正在尝试使用 VB.NET 打开一个随机访问文件我在尝试访问该文件时收到以下错误消息Error 75 (Access to the path ....is denied)。有什么我必须改变来解决这个问题吗?

Structure StdSections
    'UPGRADE_WARNING: Fixed-length string size must fit in the buffer. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="3C1E4426-0B80-443E-B943-0627CD55D48B"'
    <VBFixedString(15), System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst:=15)> Public A() As Char 'BEAM  --- complete beam designation          15
    'UPGRADE_WARNING: Fixed-length string size must fit in the buffer. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="3C1E4426-0B80-443E-B943-0627CD55D48B"'
    <VBFixedString(2), System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst:=2)> Public B() As Char 'DSG   --- shape  ie "W" or "C"                2
    Dim C As Single 'DN    --- nominal depth of section            4
    Dim d As Single 'WGT   --- weight                              4
    .
    .
    .
End structure
''Note 'File1' holds complete path!
        Public std As StdSections
        Dim i,ffr,fLength,lastmembNo as integer
        sectionFound = False

        fLength = Len(std)
        If fLength = 0 Then fLength = 168 ' 177
        ffr = FreeFile()
        'FileOpen(ffr, File1, OpenMode.Random, , , fLength)
        FileOpen(ffr, File1, OpenMode.Random, OpenAccess.ReadWrite, OpenShare.LockRead, fLength)
        >>Error 75 (Access to the path ....is denied) << path is perfectly good!!!
        lastmembNo = CInt(LOF(ffr)) \ fLength
        'ReDim std(lastmembNo)
        For i = 1 To lastmembNo
            FileGet(ffr, std, i)
               If Trim(memberID) = Trim(std.A) Then
                    sectionFound = True
                end if
        next i
4

1 回答 1

0

首先要检查的是对相关文件的权限。“访问路径被拒绝”并不意味着路径错误或无效,而是您没有权限,或者文件被另一个进程锁定。还有一种可能性是路径变量中的拼写错误(示例中的 File1)

于 2012-09-16T18:20:05.467 回答