Backends/SiaNet.Backend.Torch/FileOperations.cs
/// <summary>
///   Write bytes to the file from the given byte array.
/// </summary>
/// <param name="data">An array containing data to be written to the file.</param>
/// <param name="n">The number of bytes to write. Pass -1 (default) to write the whole array.</param>
/// <returns>The number of bytes written.</returns>
Write bytes to the file from the given byte array.
Write bytes to the file from the given byte array .
public long WriteBytes(byte[] data, int n = -1)
        {
            if (n < -1)
                throw new ArgumentOutOfRangeException("n cannot be less than -1");
            n = (n == -1) ? data.Length : Math.Min(n, data.Length);
            unsafe
            {
                fixed (byte *dest = data)
                {
                    var writtenItems = THFile_writeByteRaw(this.handle, (IntPtr)dest, n);
                    return writtenItems;
                }
            }
        }
public long WriteBytes ( byte [ ] data , int n = - 1 ) { if ( n < - 1 ) throw new ArgumentOutOfRangeException ( " " ) ; n = ( n == - 1 ) ? data . Length : Math . Min ( n , data . Length ) ; unsafe { fixed ( byte * dest = data ) { var writtenItems = THFile_writeByteRaw ( this . handle , ( IntPtr ) dest , n ) ; return writtenItems ; } } }
Write bytes to the file from the given byte array.
Write bytes to the file from the given byte array .
The number of bytes written.
The number of bytes written .
data
byte[]
An array containing data to be written to the file.
An array containing data to be written to the file .
n
int
The number of bytes to write. Pass -1 (default) to write the whole array.
The number of bytes to write . Pass - 1 ( default ) to write the whole array .