dinotom Posted July 11, 2019 Posted July 11, 2019 Can files be read from the web or the cloud? I am trying to read this file but get the file open error. #include <FileConstants.au3> #include <MsgBoxConstants.au3> ;Assign the file path to a variable Local $sFilePath = "C:\Automation\test.txt" Local $sFilePathAzure ="https://batlgroupimages.blob.core.windows.net/files/test.txt" Local $nLineNumberToLookFor = 0 ;Open the file test.txt in append mode. ;If the folder C:\Automation does not exist, it will be created. Local $hFileOpen = FileOpen($sFilePathAzure, $FO_APPEND + $FO_CREATEPATH) ;Display a message box in case of any errors. If $hFileOpen = -1 Then MsgBox($MB_SYSTEMMODAL, "", "An error occurred while opening the file.") EndIf ;Set the file position to beginning for reading the data from the beginning of the file. FileSetPos($hFileOpen, 0, $FILE_BEGIN) ;Read the data from the file using the handle returned by FileOpen ;Local $sFileRead = FileRead($hFileOpen) ;Read the 2nd line of data from the file using the handle returned by FileOpen Local $sFileReadLine = FileReadLine ($hFileOpen,2) ;Close the handle returned by FileOpen. FileClose($hFileOpen)
FrancescoDiMuro Posted July 11, 2019 Posted July 11, 2019 (edited) @dinotom Download it and open it, or, use _INET* functions to get the text of the file and process it Edited July 11, 2019 by FrancescoDiMuro Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
dinotom Posted July 11, 2019 Author Posted July 11, 2019 @FrancescoDiMuro Download it, is different than opening it? How do you download files from the cloud?
FrancescoDiMuro Posted July 11, 2019 Posted July 11, 2019 Just now, dinotom said: Found it, use InetGet Exactly what I was going to write Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
mikell Posted July 11, 2019 Posted July 11, 2019 $s = BinaryToString(InetRead("https://batlgroupimages.blob.core.windows.net/files/test.txt")) Msgbox(0,"", $s) $n = 2 ; # line to read $2nd_line = StringRegExpReplace($s, '(?m)(^\N*\R?){' & $n-1 & '}(.*)(?1)*', "$2") Msgbox(0,"", $2nd_line)
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now