YellowLab Posted December 14, 2008 Share Posted December 14, 2008 I have a script that reads a file to an Array, modifies the array, deletes the original file and then writes a new one from the array. In XP this works perfectly. I have others who are using it in Vista (I don't have Vista and can't check) and are having problems: every time a new file is being created or the existing file is being overwritten only with the new information. It sounds like the file isn't being written to the array. Here is the portions of the code that deal with detecting and writing the file. ;SNIP If @OSVersion = "WIN_VISTA" Then $FileName = @UserProfileDir & "\AppData\Local\Ascaron Entertainment\Sacred 2\OptionsCustom.txt" Else $FileName = StringReplace(@AppDataDir,"Application Data","Local Settings\Application Data\Ascaron Entertainment\Sacred 2\") & "OptionsCustom.txt" EndIf If FileExists($FileName) Then $bFileExists=TRUE _FileReadToArray($FileName,$arFile) EndIf ;SNIP If $bFileExists Then FileDelete($FileName) _FileWriteFromArray($FileName,$arFile,1) Anybody have any suggestions or things to try or do differently? Thanks, Bob You can't see a rainbow without first experiencing the rain. Link to comment Share on other sites More sharing options...
tittoproject Posted December 14, 2008 Share Posted December 14, 2008 I don't know whether it could be useful or not, but another way to detect the "Local AppData" directory is this: $LocalAppData = RegRead('HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders', 'Local AppData') Unfortunately (or fortunately, it depends on the point view ) , I cannot test it on Vista. Link to comment Share on other sites More sharing options...
MHz Posted December 15, 2008 Share Posted December 15, 2008 Vista introduces some new Environmental Variables. One of those new variables is %LOCALAPPDATA%. If you test for the existence of it then you will know that you are running on Vista or later version of Windows and you can react to that condition. ; Vista has this environmental variable $AppDataLocalDir = EnvGet('LOCALAPPDATA') If $AppDataLocalDir <> '' Then ; the variable exists so show the result MsgBox(0x40000, Default, _ '"%LOCALAPPDATA%" = "' & $AppDataLocalDir & '"') EndIf Link to comment Share on other sites More sharing options...
Ealric Posted December 15, 2008 Share Posted December 15, 2008 Vista introduces some new Environmental Variables. One of those new variables is %LOCALAPPDATA%. If you test for the existence of it then you will know that you are running on Vista or later version of Windows and you can react to that condition. ; Vista has this environmental variable $AppDataLocalDir = EnvGet('LOCALAPPDATA') If $AppDataLocalDir <> '' Then ; the variable exists so show the result MsgBox(0x40000, Default, _ '"%LOCALAPPDATA%" = "' & $AppDataLocalDir & '"') EndIf Just adding some more to what MHz is stating since I run XP, Vista-32, and Vista-64... Some changes to note: Vista uses a virtual store for some Program Files. The path is usually: AppData\Local\VirtualStore\Program Files\.... For normal (non-game related) programs, the above is generally the correct path for stored projects. For (game-related) programs the following is generally used: Public\Games\NameOfGame\.... So, if you check for the existence of the local app directory like MHz noted, you can determine if it exists. If it exists, you are in the root of AppData\Local\... and would still have to get to the VirtualStore\Program Files\ if you need to go further... Just an fyi.. hope it helps. My Projects: [topic="89413"]GoogleHack Search[/topic], [topic="67095"]Swiss File Knife GUI[/topic], [topic="69072"]Mouse Location Pointer[/topic], [topic="86040"]Standard Deviation Calculator[/topic] 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