I like to read the whole file into an array list and then search for the item that is needed, like so.....
Code:
If FileExist( "Config.ini" ) Then
AlConfig.Clear ' Clear the current configuration
FileOpen( ConfigFile , "Config.ini" , cRead,, cASCII ) ' Open config file and read into the current configuration
Data = FileRead( ConfigFile )
Do Until Data = EOF
AlConfig.Add( Data )
Data = FileRead( ConfigFile )
Loop
FileClose( ConfigFile )
Index = AlConfig.IndexOf( "CONFIG" ) ' Find start of the config settings
AlConfig.Item( Index + 1 ) = "AutoSchedule=Enabled" ' Update Autoschedule setting
Else
CreateConfig ' If config file is missing create a new file before updating
End If
I find that doing it this way is fast, it also releases the file for other uses and it is easy to find the item you require using IndexOf on the array list which in this example is called AlConfig.
Hope this helps.
Regards,
RandomCoder
__________________
Desktop: Pentium D 920 (2.8GHz, 4MB L2 Cache, 800MHz FSB), 1024MB, 256MB Radeon X600, 250GB HD.
Device : Axim X51v XScale 624MHz, 3.7" VGA, 64MB SDRAM, 256MB Flash ROM + 1Gb SD.
"Defeat never comes to any man until he admits it."Josephus Daniels
|