narayanjr Posted June 15, 2007 Share Posted June 15, 2007 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 Link to comment Share on other sites More sharing options...
smashly Posted June 15, 2007 Share Posted June 15, 2007 (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 June 15, 2007 by smashly Link to comment Share on other sites More sharing options...
Gif Posted June 15, 2007 Share Posted June 15, 2007 (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 June 15, 2007 by c4nm7 Link to comment Share on other sites More sharing options...
narayanjr Posted June 15, 2007 Author Share Posted June 15, 2007 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 Link to comment Share on other sites More sharing options...
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