blackmage999 0 Posted February 23, 2011 (edited) #Include <File.au3>$PlayerName = ClipGet();;;;;open credit file or create newIf FileExists(@DesktopDir & "\PlayerCredits\" + $PlayerName & ".txt") Then $PlayerCreditFile = FileOpen(@DesktopDir & "\PlayerCredits\" + $PlayerName & ".txt", 0)Else _FileCreate(@DesktopDir & "\PlayerCredits\" + $PlayerName & ".txt") $PlayerCreditFile = FileOpen(@DesktopDir & "\PlayerCredits\" + $PlayerName & ".txt", 0)EndIf;;;;;get player credits$PlayerCredit = FileReadLine($PlayerCreditFile)FileClose($PlayerCreditFile)Im using this code in one of my scripts, but it fails to create a .txt. any help on what the problem might be would be appricatedEdit: I just relized i used +'s instead of &'s...fixed, but still fails to create my .txt Edited February 23, 2011 by blackmage999 Share this post Link to post Share on other sites
Bowmore 97 Posted February 23, 2011 Try this. $PlayerCreditFile = FileOpen(@DesktopDir & "\PlayerCredits\" & $PlayerName & ".txt", 9) and read about the mode option for fileopen() in the help file "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook Share this post Link to post Share on other sites
Varian 8 Posted February 23, 2011 Evidently _FileCreate cannot create a new directory. This works #include <File.au3> $PlayerName = ClipGet() ;;;;;open credit file or create new If FileExists(@DesktopDir & "\PlayerCredits\" & $PlayerName & ".txt") Then $PlayerCreditFile = FileOpen(@DesktopDir & "\PlayerCredits\" & $PlayerName & ".txt", 0) Else If Not FileExists(@DesktopDir & "\PlayerCredits") Then DirCreate(@DesktopDir & "\PlayerCredits") If Not _FileCreate(@DesktopDir & "\PlayerCredits\" & $PlayerName & ".txt") Then MsgBox(4096, @DesktopDir & "\PlayerCredits\" & $PlayerName & ".txt", " Error Creating/Resetting log. error:" & @error & @LF & @DesktopDir & "\PlayerCredits\" & $PlayerName & ".txt") Exit EndIf $PlayerCreditFile = FileOpen(@DesktopDir & "\PlayerCredits\" & $PlayerName & ".txt", 0) EndIf ;;;;;get player credits $PlayerCredit = FileReadLine($PlayerCreditFile) FileClose($PlayerCreditFile) Share this post Link to post Share on other sites