Sign in to follow this  
Followers 0
narayanjr

FileOpen(), iniwrite()

4 posts in this topic

If Not FileExists("C:\Program Files\ArW-Pikid\Settings.ini") Then
    FileOpen("C:\Program Files\ArW-Pikid\Settings.ini", 9)
    IniWrite("C:\Program Files\ArW-Pikid\Settings.ini", "Settings", "Color_Mode", "")
    IniWrite("C:\Program Files\ArW-Pikid\Settings.ini", "Settings", "Tele_Key", "")
    ShellExecute("C:\Program Files\ArW-Pikid\Settings.ini", "", "C:\Program Files\ArW-Pikid\")
    WinWait("Settings - Notepad")
    While WinActivate("Settings - Notepad")
        sleep(2000)
    WEnd
    FileClose("C:\Program Files\ArW-Pikid\Settings.ini")
EndIf

If the folder does not exist I want it to create the folder then make the file and write the stuff to it.

When the folder does not exist and it is made it wont save. I get this error,

Cannot create the C:\Program Files\ArW-Pikid\Settings.ini file

Make sure that the path and filename are correct.

But if the folder already exists then it has no problem saving the file.

Any help would be appreciated. Thanks

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Tip: Lose the FileOpen() and FileClose()

IniWrite() doesn't need to work successfully.

If Not FileExists(@ProgramFilesDir & "\ArW-Pikid") Then
    $dc = DirCreate(@ProgramFilesDir & "\ArW-Pikid")
    If $dc = 1 Then
        IniWrite(@ProgramFilesDir & "\ArW-Pikid\Settings.ini", "Settings", "Color_Mode", "")
        IniWrite(@ProgramFilesDir & "\ArW-Pikid\Settings.ini", "Settings", "Tele_Key", "")
        ShellExecute(@ProgramFilesDir & "\ArW-Pikid\Settings.ini")
    EndIf
ElseIf FileExists(@ProgramFilesDir & "\ArW-Pikid") Then
    IniWrite(@ProgramFilesDir & "\ArW-Pikid\Settings.ini", "Settings", "Color_Mode", "")
    IniWrite(@ProgramFilesDir & "\ArW-Pikid\Settings.ini", "Settings", "Tele_Key", "")
    ShellExecute(@ProgramFilesDir & "\ArW-Pikid\Settings.ini")  
EndIf

Cheers

Edited by smashly

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Try this:

If FileExists("C:\Program Files\ArW-Pikid\Settings.ini") = 0 Then
    DirCreate("C:\Program Files\ArW-Pikid\")
    IniWrite("C:\Program Files\ArW-Pikid\Settings.ini", "Settings", "Color_Mode", "")
    IniWrite("C:\Program Files\ArW-Pikid\Settings.ini", "Settings", "Tele_Key", "")
    ShellExecuteWait("C:\Program Files\ArW-Pikid\Settings.ini", "", "C:\Program Files\ArW-Pikid\")
EndIf
Edited by c4nm7

Share this post


Link to post
Share on other sites

Thank You,

I did a search for create but i got over 200 things and probably missed it when i looked through some of them

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