nxtlib/src/Brick.cs
/// <summary>
/// Downloads a file from the NXT to a local location.
/// </summary>
/// <param name="filenameonbrick">The target file to upload to, with expension.</param>
/// <param name="filenamelocal">The name of the file to read from local disk.</param>
Downloads a file from the NXT to a local location.
Downloads a file from the NXT to a local location .
public void DownloadFile(string filenameonbrick, string filenamelocal)
        {
            if (File.Exists(filenamelocal))
            {
                File.Delete(filenamelocal);
            }
            if (!link.DoesExist(filenameonbrick)) { throw new NXTFileNotFound(); }
            Protocol.NXTOpenReadReply reply = link.OpenRead(filenameonbrick);
            byte[] contents = link.Read(reply.handle, (ushort)reply.fileSize);
            System.Threading.Thread.Sleep(100);
            link.Close(reply.handle);
            using (var stream = System.IO.File.OpenWrite(filenamelocal))
            {
                stream.Write(contents, 0, contents.Length);
                stream.Close();
            }
            return;
        }
public void DownloadFile ( string filenameonbrick , string filenamelocal ) { if ( File . Exists ( filenamelocal ) ) { File . Delete ( filenamelocal ) ; } if ( ! link . DoesExist ( filenameonbrick ) ) { throw new NXTFileNotFound ( ) ; } Protocol . NXTOpenReadReply reply = link . OpenRead ( filenameonbrick ) ; byte [ ] contents = link . Read ( reply . handle , ( ushort ) reply . fileSize ) ; System . Threading . Thread . Sleep ( 100 ) ; link . Close ( reply . handle ) ; using ( var stream = System . IO . File . OpenWrite ( filenamelocal ) ) { stream . Write ( contents , 0 , contents . Length ) ; stream . Close ( ) ; } return ; }
Downloads a file from the NXT to a local location.
Downloads a file from the NXT to a local location .
//Delete File, if Exists //File.Create(filenamelocal); //Check if file exists //Prepare NXT for reading //Close Remote Files //Write byte array to local file
filenameonbrick
string
The target file to upload to, with expension.
The target file to upload to with expension .
filenamelocal
string
The name of the file to read from local disk.
The name of the file to read from local disk .