Jump to content

How to read a notepad++ file?


 Share

Recommended Posts

Hi guys, i am having an issue reading a notepadd++ file...

#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

Example()

Func Example()
    ; Open the file for reading and store the handle to a variable.
    Local $hFileOpen = FileOpen("test123.html", $FO_READ)
    If $hFileOpen = -1 Then
        MsgBox($MB_SYSTEMMODAL, "", "An error occurred when reading the file.")
        Return False
    EndIf

    ; Read the contents of the file using the handle returned by FileOpen.
    Local $sFileRead = FileRead($hFileOpen)

    ; Close the handle returned by FileOpen.
    FileClose($hFileOpen)

    ; Display the contents of the file.
    MsgBox($MB_SYSTEMMODAL, "", "Contents of the file:" & @CRLF & $sFileRead)

    
EndFunc   ;==>Example

It does seem that i get an error but why?

Link to comment
Share on other sites

What is the error ? Where is the link between your script and Notepad++ ?

If the problem is that the file does not open, try the specify the file full path :

$hFileOpen = FileOpen(@ScriptDir & "\test123.html", $FO_READ)
; or
$hFileOpen = FileOpen("c:\full\path\to\test123.html", $FO_READ)

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...