Skip to content

format

typescript
FileStream.ReadBytes(stream, count)

class: FileStream

description

Reads the specified number of bytes from the current stream and stores them in the target memory stream.

parameter

param_nametypedescription
streamMemoryStreamThe target memory stream.
countnumber?The number of bytes to read.

reture

typedescription
void

code example

javascript
function Test(path: string) {  
    try {
        let fileWrite = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write);  
        let msw = new MemoryStream();  
        msw.SetString("test111111");  
        msw.SetString("test222222");  
        fileWrite.WriteBytes(msw);  
        fileWrite.Close();  

        let fileRead = new FileStream(path, FileMode.Open, FileAccess.Read);  
        let msr = new MemoryStream();  
        fileRead.ReadBytes(msr);  
        Debug.Log(msr.GetString());  
        Debug.Log(msr.GetString());  
        fileRead.Close();  
    } catch (error) {
        Debug.Error(error);
    }
}