|
-
Nov 6th, 2006, 08:24 AM
#1
Thread Starter
Member
[RESOLVED] Read Write API - Setting file attributes
Has anyone else had problems with this API?
I can't get the example to work. It always returns zero for nSizw.
nSize = GetFileSize(hOrgFile, 0)
Then I get Subscript out of range at
ReDim bBytes(1 To nSize - Int(nSize / 2)) As Byte.
Is this a know problem which people can help me with, or does anyone know a better way to ensure a file they are trying to write to is not "Read Only", and make "Read & Write".
Thanks
-
Nov 6th, 2006, 08:44 AM
#2
Junior Member
Re: Read Write API - Setting file attributes
Hello SlapHead109, I am just a new member but I know little about API may be this can help you in returning size of files, just don't read the bottom of my code as it belongs to another language which has the same function:
VB Code:
Private Const OF_READ = &H0&
'Equivalent to Kark98_K Function of OKL
Private Declare Function lOpen Lib "kernel32" Alias "_lopen" (ByVal lpPathName As String, ByVal iReadWrite As Long) As Long
'Equivalent to MP_40 Or MP_44 Or WEHR_43 Structure of OKL
Private Declare Function lclose Lib "kernel32" Alias "_lclose" (ByVal XFile As Long) As Long
'OKL has a fixed function: PPSH_BAR.SYS{SIZE OBS;}
Private Declare Function GetFileSize Lib "kernel32" (ByVal hFile As Long, lpFileSizeHigh As Long) As Long
Dim lpFSHigh As Long
Public Sub GetInfoF(FilePath As String)
Dim Pointer As Long, sizeofthefile As Long
Pointer = lOpen(FilePath, OF_READ)
'size of the file
sizeofthefile = GetFileSize(Pointer, lpFileSizeHigh)
Label1.Caption = sizeofthefile & " bytes"
lclose Pointer
End Sub
Private Sub command1_Click()
CommonDialog1.ShowOpen
GetInfoF CommonDialog1.FileName
End Sub
Private Sub Form_Load()
With CommonDialog1
.DialogTitle = "Select a file"
.Filter = "All the files|*.*"
End With
Command1.Caption = "Select a file"
End Sub
-
Nov 7th, 2006, 01:36 AM
#3
Member
Re: Read Write API - Setting file attributes
Use FileSystemObject to change the file attribute (Add ref to Microsoft Scripting Runtime)
 Rajneesh
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|