Jump to content

Search the Community

Showing results for tags 'end'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 1 result

  1. Because in AutoIt's helpfile there is very poor example for function FileSetEnd() I add here for the reference my better example demonstrating expanding/truncating size of file also with retaining of original data. Note: FileSetEnd() was added in AutoIt 3.3.13.11 (2014-07-27) #include <FileConstants.au3> #include <MsgBoxConstants.au3> Example() Func Example() Local Const $sFilePath = @TempDir & "\FileSetEnd.txt" ; create file 6 bytes in size FileDelete($sFilePath) FileWrite($sFilePath,'abc123') MsgBox($MB_SYSTEMMODAL, FileGetSize($sFilePath), FileRead($sFilePath)) ; 6 / abc123 ; expand size of file to 9 bytes but don't write any data to expanded area $hFileOpen = FileOpen($sFilePath, $FO_APPEND) FileSetPos($hFileOpen, 9, $FILE_BEGIN) FileSetEnd($hFileOpen) FileClose($hFileOpen) MsgBox($MB_SYSTEMMODAL, FileGetSize($sFilePath), FileRead($sFilePath)) ; 9 / abc123 ; write data to expanded area (more than size of expanded area) so size of file will auto expand to 12 bytes (6+6) $hFileOpen = FileOpen($sFilePath, $FO_APPEND) FileSetPos($hFileOpen, 6, $FILE_BEGIN) FileWrite($hFileOpen,'def456') FileClose($hFileOpen) MsgBox($MB_SYSTEMMODAL, FileGetSize($sFilePath), FileRead($sFilePath)) ; 12 / abc123def456 ; truncate size of file to 9 bytes $hFileOpen = FileOpen($sFilePath, $FO_APPEND) FileSetPos($hFileOpen, 9, $FILE_BEGIN) FileSetEnd($hFileOpen) FileClose($hFileOpen) MsgBox($MB_SYSTEMMODAL, FileGetSize($sFilePath), FileRead($sFilePath)) ; 9 / abc123def FileDelete($sFilePath) EndFunc ;==>Example Remarks: - current position for FileSetEnd() can be changed by FileSetPos() - for expanding/truncating of existing files with preserved content have to be used mode $FO_APPEND in FileOpen() EDIT: This my example in slightly changed version was added as example #2 to AutoIt's helpfile in version 3.3.13.14 (2014-08-02).
×
×
  • Create New...