Sign in to follow this  
Followers 0
GreYFoX

Reading a certain offset of the file & writing to it

3 posts in this topic

Reading a certain offset of the file & writing to it

the file i'm talking about is 200mb+

so i need to read a certain offset to offset of the file

and write to it again

thanks

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Reading a certain offset of the file & writing to it

the file i'm talking about is 200mb+

so i need to read a certain offset to offset of the file

and write to it again

thanks

Here are two suggestions, but I would wait to see if anyone gives a better answer before putting any time into it because I don't know if this is the best way. Certainly I have often wondered about this, and the documentation for the File functions makes it look difficult. There doesn't appear to be a way in AutIt to write to a file at an offset from the beginning or end and then overwrite.

So this is what I would try.

$hFRead = FileOpen("???",16);Open the file in binary and read mode.
$hFWrite = FileOpen("temp",16 + 1);Open a file to write to in binary and write mode.

$start = Fileread($hf,$offset);read up to the offset you want
FileWrite($hfWRite,$offset);copy this part to temp file

$StringToWRite = "something";what you want to write at this point
FileRead($hfRead,Stringlen($StringToWrite);get past that length in file we are reading
FileWrite($hFWRite,StringToBinary($StringToWrite))

;from here just read chunks of data, say 1Mb at a time, from the file and write them to the temp file untill eof

Or

You could read the whole file using

$Text = FileRead($FileName)

Then say

$Text = StringReplace(StringMid($text,offset,StringLen($text_to_overwrite),$text_to_overwrite)

FileWrite("NewFileName",$Text)

Edited by martin

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Hi,

Use "TailRW" in my signature.

There are examples of setting "position" in binary to start writing, and whether to insert or replace in the zip in my sig. [then don't need the slow file read of a big file..]

Let me know..

best, randall

Share this post


Link to post
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
Sign in to follow this  
Followers 0