Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include-once
- #include <Array.au3>
- ; #FUNCTION# ====================================================================================================================
- ; Name...........: _FileDeleteLine
- ; Description ...: Delete a line in the file
- ; Syntax.........: _FileDeleteLine($sFilePath, $lineNumber)
- ; Parameters ....: $sFilePath - File name or file path
- ; $lineNumber - Line number in the file that you want to delete
- ; Return values .: Success - True
- ; Failure - Flase
- ; Author ........: Juno_okyo <junookyo@gmail.com>
- ; ===============================================================================================================================
- Func _FileDeleteLine($sFilePath, $lineNumber)
- If Not FileExists($sFilePath) Or Not IsNumber($lineNumber) Then Return False
- ;=> Remove line using array
- Local $aFile = FileReadToArray($sFilePath)
- _ArrayDelete($aFile, $lineNumber - 1)
- If @error Then Return False
- ;=> Rewrite
- Local $fp = FileOpen($sFilePath, 2 + 256)
- For $line In $aFile
- FileWriteLine($fp, $line)
- Next
- FileClose($fp)
- Return True
- EndFunc
Add Comment
Please, Sign In to add comment