nxtlib/src/Brick.cs
/// <summary>
/// Uploads a file to the NXT, overwriting contents.
/// </summary>
/// <param name="filenamelocal">The name of the file to read from local disk.</param>
/// <param name="filenameonbrick">The target file to upload to, with expension.</param>
Uploads a file to the NXT, overwriting contents.
Uploads a file to the NXT overwriting contents .
public void UploadFile(string filenamelocal, string filenameonbrick)
        {
            if (link.DoesExist(filenameonbrick))
            {
                link.Delete(filenameonbrick);
            }
            byte[] localcontents;
            using (var stream = System.IO.File.OpenRead(filenamelocal))
            {
                localcontents = new byte[(int)stream.Length];
                int offset = 0;
                while (offset < localcontents.Length)
                {
                    int chunk = stream.Read(localcontents, offset, localcontents.Length - offset);
                    if (chunk == 0) { throw new IOException("Not all bytes written!"); }
                    offset += chunk;
                }
                stream.Close();
            }
            UInt32 filesize = 0;
            filesize = (UInt32)localcontents.Length;
            byte filehandle = link.OpenWrite(filenameonbrick, filesize);
            int reply = link.Write(filehandle, localcontents);
            link.Close(filehandle);
            return;
        }
public void UploadFile ( string filenamelocal , string filenameonbrick ) { if ( link . DoesExist ( filenameonbrick ) ) { link . Delete ( filenameonbrick ) ; } byte [ ] localcontents ; using ( var stream = System . IO . File . OpenRead ( filenamelocal ) ) { localcontents = new byte [ ( int ) stream . Length ] ; int offset = 0 ; while ( offset < localcontents . Length ) { int chunk = stream . Read ( localcontents , offset , localcontents . Length - offset ) ; if ( chunk == 0 ) { throw new IOException ( " " ) ; } offset += chunk ; } stream . Close ( ) ; } UInt32 filesize = 0 ; filesize = ( UInt32 ) localcontents . Length ; byte filehandle = link . OpenWrite ( filenameonbrick , filesize ) ; int reply = link . Write ( filehandle , localcontents ) ; link . Close ( filehandle ) ; return ; }
Uploads a file to the NXT, overwriting contents.
Uploads a file to the NXT overwriting contents .
//Delete File, if Exists //Read Local File //Find Length of Local File //Open New File for Reading //Copy Local to Remote //Close Remote Files
filenamelocal
string
The name of the file to read from local disk.
The name of the file to read from local disk .
filenameonbrick
string
The target file to upload to, with expension.
The target file to upload to with expension .