For Programmers: Free Programming Magazines  


Home > Archive > Visual Basic > March 2006 > File Attribute 8225









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author File Attribute 8225
Rama Raju

2006-03-28, 6:56 pm

Hi,

When i am using the GetAttr, we will get the the integer 8225. But when we
set the attribute, we get a error message saying "invalid procedure call or
argument".

The below is the code.. Could any one please help me why this error is
getting displayed.

regards
Raju

Dim LiveAttrib As Integer

LiveAttrib = GetAttr("C:\Progra~1\RIO\AGENDA\LIVE\RIO.DB")

' MsgBox ("LiveAttrib - " & LiveAttrib)
' MsgBox ("LiveAttrib - Err.Number & Err.Description & LiveAttrib " & _
' Err.Number & " - " & " - " & Err.Description & LiveAttrib)

SetAttr "C:\Progra~1\RIO\AGENDA\LIVE\RIO.DB", ATTR_NORMAL
' MsgBox (" SetAttr - Err.Number & Err.Description & LiveAttrib " & _
' Err.Number & " - " & " - " & Err.Description & LiveAttrib)

LiveAttrib = 0
FileCopy "C:\Progra~1\RIO\AGENDA\LIVE\WORKING\RIO.DB",
"C:\Progra~1\RIO\AGENDA\LIVE\RIO.DB"
MsgBox ("FileCopy - Err.Number & Err.Description & LiveAttrib " & _
Err.Number & " - " & " - " & Err.Description & LiveAttrib)


SetAttr "C:\Progra~1\RIO\AGENDA\LIVE\RIO.DB", LiveAttrib
MsgBox (" SetAttr - Err.Number & Err.Description & LiveAttrib " & _
Err.Number & " - " & " - " & Err.Description & LiveAttrib)
Mike D Sutton

2006-03-28, 6:56 pm

> When i am using the GetAttr, we will get the the integer 8225. But when we
> set the attribute, we get a error message saying "invalid procedure call or
> argument".
>
> The below is the code.. Could any one please help me why this error is
> getting displayed.

<code snipped>

VB's functions only support a limited number of attributes, use the Get/SetFileAttributes() API calls instead:

'***
Private Declare Function GetFileAttributes Lib "Kernel32.dll" (ByVal lpFileName As String) As Long
Private Declare Function SetFileAttributes Lib "Kernel32.dll" ( _
ByVal lpFileName As String, ByVal dwFileAttributes As Long) As Long

....

Const FileName As String = "C:\Progra~1\RIO\AGENDA\LIVE\RIO.DB"

Dim LiveAttrib As Long ' Re-declared as long
Dim RetVal As Long

LiveAttrib = GetFileAttributes(FileName)

....

RetVal = SetFileAttributes(FileName, LiveAttrib)

If (RetVal <> 0) Then _
Call MsgBox("Error: " & RetVal & " (" & Err.LastDLLError & ")")
'***

Hope this helps,

Mike


- Microsoft Visual Basic MVP -
E-Mail: EDais@mvps.org
WWW: Http://EDais.mvps.org/


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com