ReadFile
Top  Previous  Next

Description

Transfers the indicated amount of bytes from the specified file in the device to the data array in memory.


Syntax


[VB]
Value=objActiveUSB.ReadFile Name, Buffer, Length


[C/C++]
HRESULT ReadFile( bstr Name, long Offset, long Length , VARIANT* pData);


Data Types
[VB]

Name: String
Offset: Long
Length: Long
Return value: Variant (Array of Bytes)


Parameters
[C/C++]

Name [in]  
String specifying the name of the file in the device  
Offset [in]  
The transfer starting position from the beginning of the file in bytes  
Length [in]  
The number of bytes to transfer from the specified file  
pData [out]  
Pointer to SAFEARRAY of bytes containing data transferred from the file  


Return Values


S_OK  
Success  
E_NOINTERFACE        
File with the specified name does not exist in the device  
E_FAIL  
Failure.  


Example


This VB code transfers data from the "UserSet1" file in the device to the DataArray in memory.

length=ActiveUSB1.GetFileSize("UserSet1")
DataArray=ActiveUSB1.ReadFile("UserSet1",0,length)


Remarks


The File Access functionality allows an application to read and write files hosted on the device. The data in those files may contain look-up tables, configuration sets, firmware, and other information.

Once you transferred the file data from the device to memory, you can save them in a file on a hard drive. Note that in order for this method to work, the Access Mode of the file should be "R" or "RW".