Next Topic

Previous Topic

Book Contents

Write

bool Write(TLuaSFTPClientHandle FileHandle,const int iOffset,string vData)

Return value

Returns true if the operation was successful or false if otherwise.

Parameters

  • FileHandle - Handle of previously opened file.
  • iOffset - Offset in bytes where to write in file.
  • sData - String of text to write.

Example

--KNM Lua API example (C) 2010 Kaseya AB
--Demonstrates the Lua SFTP client class

sftp = TLuaSFTPClient()
hFileHandle = TLuaSFTPClientHandle()

--Open the file
hFileHandle = TLuaSFTPClientHandle()
if sftp:Open_ForWrite("test.txt",hFileHandle) == false then
	SetExitStatus("Open of file failed",false)
	return
end

--Create a string and write it to the begining of the file
sString = [[ test text ]];
if sftp:Write(hFileHandle,0,sString) == false then
	SetExitStatus("Write failed",false)
	return
end

--Close the file
sftp:Close(hFileHandle)