-
[RESOLVED] Retrieve both the source and destination when they are either side of an if statement
Hi,
How could I retrieve both the source and destination when they are either side of an if statement?
Here is my code:
vb Code:
Private Sub WinVersion()
Dim osinfo As OSVERSIONINFO
Dim retvalue As Integer
Dim sNextFile As String
osinfo.dwOSVersionInfoSize = 148
osinfo.szCSDVersion = Space$(128)
retvalue = GetVersionExA(osinfo)
If osinfo.dwMajorVersion = 7 Then 'Windows 7
If Not Dir$(App.path & "\xlive.dll") <> "" Then
path = "C:\Users\" & sUserName & "\AppData\Local\Rockstar Games\GTA IV\Settings\"
source = path
Else
path = "C:\Users\" & sUserName & "\Documents\Rockstar Games\GTA IV\savegames\"
destination = path
End If
ElseIf osinfo.dwMajorVersion = 6 Then 'Vista
If Not Dir$(App.path & "\xlive.dll") <> "" Then
path = "C:\Users\" & sUserName & "\AppData\Local\Rockstar Games\GTA IV\Settings\"
source = path
Else
path = "C:\Users\" & sUserName & "\Documents\Rockstar Games\GTA IV\savegames\"
destination = path
End If
ElseIf osinfo.dwMajorVersion = 5 Then 'XP
If Not Dir$(App.path & "\xlive.dll") <> "" Then
path = "C:\Documents and Settings\" & sUserName & "\Local Settings\Application Data\Rockstar Games\GTA IV\Settings\"
source = path
Else
path = "C:\Users\" & sUserName & "\Documents\Rockstar Games\GTA IV\savegames\"
destination = path
End If
'ElseIf osinfo.dwMajorVersion = 4 Then 'Win2k etc.
Else
End If
'copy
'Delete (path)
End Sub
I need to set the source and destination folders depending on whether or not the "xlive.dll" is location in the folder or not. If there is a better why to copy the files please show me.
Thanks,
Nightwalker
-
Re: Retrieve both the source and destination when they are either side of an if state
you should not be hardcoding the paths to folders that are not of fixed location (userdata), but returning them using specialfolders API or other method that will return the correct location, just because there is a default location, no guarantee they have not been moved
you could try Environ("appdata")
-
Re: Retrieve both the source and destination when they are either side of an if state
Quote:
Originally Posted by
westconn1
you could try Environ("appdata")
Ah ok, although, I tried that and it returned the "AppData\Roaming" instead of the "Local" folder when the files are actually located.
-
Re: Retrieve both the source and destination when they are either side of an if state
path = "C:\Users\" .......
Don't have that folder. Your program wouldn't work on my machine.
How could I retrieve both the source and destination when they are either side of an if statement?
I see in your code you have all these If.....Else.....End If and the likes where two variables called destination and source, although I do not see them Dimentioned, are being initialized with values. Now you ask how to retrieve both of these values. What do you mean? You have both of them at the end of your last End If statement. Am I not reading your post correctly?
-
Re: Retrieve both the source and destination when they are either side of an if state
Quote:
Originally Posted by
jmsrickland
path = "C:\Users\" .......
Don't have that folder. Your program wouldn't work on my machine.
What should I put instead? The hard-coded paths in the code above are in-fact those used by thew game on different operating system so how would I use those locations without hard coding the paths?
Quote:
How could I retrieve both the source and destination when they are either side of an if statement?
I see in your code you have all these If.....Else.....End If and the likes where two variables called destination and source, although I do not see them Dimentioned, are being initialized with values. Now you ask how to retrieve both of these values. What do you mean? You have both of them at the end of your last End If statement. Am I not reading your post correctly?
I need to set both the source and destination regardless of what the path is. If the destination path is different from the default (source) path then the files would be copied to new location.
-
Re: Retrieve both the source and destination when they are either side of an if state
at least from the roaming folder you know the correct path for the specific machine to appdata. so just change the last subfolder form roaming to local, then check it exists, different in XP of course
probably a select case would be better to all the iffs
-
Re: Retrieve both the source and destination when they are either side of an if state
I don't think you need to do all those If......End If when you can just use an API that gets you the correct path from the operating system.
Environ("appdata")
Now that one works for me but the other guy said it returned an incorrect path. Can't debug that one.
I think there is another API but I do not know it's name.
Why does your program have to use those paths anyway? Can you not just use App.Path? If the current App.Path does not have the inner folders you want or need to have then you can create them on the fly.
Do other applications (yours or someone elses) depend on those particular paths in relation to your programm?
-
Re: Retrieve both the source and destination when they are either side of an if state
Quote:
Originally Posted by
jmsrickland
Why does your program have to use those paths anyway? Can you not just use App.Path? If the current App.Path does not have the inner folders you want or need to have then you can create them on the fly.
I need to check the location of the files for GTA IV under certain operating systems.
Quote:
Do other applications (yours or someone elses) depend on those particular paths in relation to your program?
Those paths are the particular locations used to save data for GTA IV.
-
Re: Retrieve both the source and destination when they are either side of an if state
Those paths are the particular locations used to save data for GTA IV.
OK. I don't know what GTA IV is
-
Re: Retrieve both the source and destination when they are either side of an if state
Quote:
Originally Posted by
jmsrickland
Those paths are the particular locations used to save data for GTA IV.
OK. I don't know what GTA IV is
It's a game.
-
Re: Retrieve both the source and destination when they are either side of an if state
Quote:
If the current App.Path
app.path is not considered a good location for datafiles and need elevation under vista or w7, or some virtualised folder is substituted
afaik gta = grand theft auto
there maybe some registry key under gta that will give the correct path
-
Re: Retrieve both the source and destination when they are either side of an if state
Quote:
Originally Posted by
westconn1
app.path is not considered a good location for datafiles and need elevation under vista or w7, or some virtualised folder is substituted
How would I change the above code, what should the above paths be?
Edit:
The variable sUserName holds the username of the currently logged in account which, is retrieved by another function, here it is.
-
Re: Retrieve both the source and destination when they are either side of an if state
It's a game.
I didn't know this. So, it's a game already made (commerical) and it uses those paths and you are making a VB program that needs to use those same paths for your program to either read or write files from those paths so that your program will function correctly. Is this correct? If not, then I don't understand why you need those exact paths.
-
Re: Retrieve both the source and destination when they are either side of an if state
Quote:
Originally Posted by
jmsrickland
It's a game.
I didn't know this. So, it's a game already made (commerical) and it uses those paths and you are making a VB program that needs to use those same paths for your program to either read or write files from those paths so that your program will function correctly. Is this correct? If not, then I don't understand why you need those exact paths.
That is correct! My program adjusts the game settings automatically so the player does not have to do it manually each time they play the game.
-
Re: Retrieve both the source and destination when they are either side of an if state
OK, now that I understand that I still do not understand your question Retrieve both the source and destination when they are either side of an if statement
Do you need to know those paths before you enter into your If.....Else.....End If clauses? Because you will know them at the end.
-
Re: Retrieve both the source and destination when they are either side of an if state
Yes, I need to set the source and destination paths regardless of the path in-case xlive.dll gets put in the folder. If xlive.dll is in the folder then the path would be different to the default path (the default path being the path used before xlive.dll was added), xlive modifies the games, one aspect of which, is that it changes the location of the save directory for the game.
-
Re: Retrieve both the source and destination when they are either side of an if state
i assume, but have never tested that the "user" folder structure remains the same, regardless of where it is located
if that is true then
environ should return the correct value for xp, but with vista and w7 it will return the roaming folder below appdata, to replace that with the local, is just a matter of replacing "roaming" with "local"
some one may shoot me down here, but i do not know if the getspecialfolders API will find the local folder as different to the roaming one
i have not really studied the criteria as to what should go into each of those folders, but i am sure there will be a white paper or something with the details, available online
-
Re: Retrieve both the source and destination when they are either side of an if state
I found this on vbhelper:
vb Code:
Declare Function MakeTree Lib "imagehlp.dll" Alias _
"MakeSureDirectoryPathExists" (ByVal lpszPath As _
String) As Long
' Create the complete directory path.
Private Sub MakePath(ByVal path As String)
Dim directories As Variant
Dim i As Integer
Dim new_dir As String
Dim dir_path As String
' Break the path into directories.
directories = Split(path, "\")
' Build the subdirectories.
For i = LBound(directories) To UBound(directories)
' Get the next directory in the path.
new_dir = directories(i)
' Make sure the entry is non-empty.
If Len(new_dir) > 0 Then
' Add the new directory to the path.
dir_path = dir_path & new_dir & "\"
' Make sure we don't just have a drive
' specification.
If Right$(new_dir, 1) <> ":" Then
' See if the directory already exists.
If Dir$(dir_path, vbDirectory) = "" Then
' The directory doesn't exist.
' Make it.
MkDir dir_path
End If
End If
End If
Next i
End Sub
Although, I'm not sure if it does what you are talking about?
-
Re: Retrieve both the source and destination when they are either side of an if state
as you are looking to locate an existing file, i do not see why that function would be useful to you at this time, that creates all sub folder required to create a specified path
search on specialfolders
-
Re: Retrieve both the source and destination when they are either side of an if state
I found this example which retrieves the path of the special folders. The only thing is that uses "shfolder.dll" instead of just the code. I would rather compile my program into a stand-alone exe rather than having to rely on external dlls, ocx, etc doing the work.
Edit:
This code by VBForums own Dave Sell does the same thing except it is in a module.
Dave Sells code still returns the "Roaming" folder whereas I need to retrieve the "Local" folder.
I replied to the above thread hopefully someone can point me in the right direction.
-
Re: Retrieve both the source and destination when they are either side of an if state
Quote:
Originally Posted by
Nightwalker83
I replied to the above thread hopefully someone can point me in the right direction.
Here is the solution:
Quote:
Originally Posted by
jpbro
Because there's a mistake in the SpecialFolders Enum:
Local_AppData = CSIDL_APPDATA
Should be:
Local_AppData = CSIDL_LOCAL_APPDATA
-
Re: Retrieve both the source and destination when they are either side of an if state
How do you declare OSVERSIONINFO
-
Re: Retrieve both the source and destination when they are either side of an if state
Like so:
vb Code:
'Source: http://social.msdn.microsoft.com/Forums/en/vbide/thread/395b12fd-ccfc-4281-b1b3-4c69b56f8b85
Declare Function GetVersionExA Lib "kernel32" (lpVersionInformation As OSVERSIONINFO) As Integer
Public Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128
End Type
Procedure :-
Private Sub WinVersion()
Dim osinfo As OSVERSIONINFO
Dim retvalue As Integer
osinfo.dwOSVersionInfoSize = 148
osinfo.szCSDVersion = Space$(128)
retvalue = GetVersionExA(osinfo)
If osinfo.dwMajorVersion = 6 Then 'Vista
ElseIf osinfo.dwMajorVersion = 5 Then 'XP
ElseIf osinfo.dwMajorVersion = 4 Then 'Win2k etc.
Else
End If
End Sub
See line two.
Edit:
I removed the previous code I had posted because after testing I found it was not working.
-
Re: Retrieve both the source and destination when they are either side of an if state
Yeah but now you're not showing how to get the correct paths and that's what I needed to know.
-
Re: Retrieve both the source and destination when they are either side of an if state
Quote:
Originally Posted by
jmsrickland
Yeah but now you're not showing how to get the correct paths and that's what I needed to know.
I'm not sure I follow! The paths I originally used were hard coded. Although, I have written this which works:
vb Code:
Private Sub WinVersion()
'Retrieve the current operating system and set the settings path accordingly
'http://social.msdn.microsoft.com/Forums/en/vbide/thread/395b12fd-ccfc-4281-b1b3-4c69b56f8b85
Dim osinfo As OSVERSIONINFO
Dim retvalue As Integer
Dim sNextFile As String
osinfo.dwOSVersionInfoSize = 148
osinfo.szCSDVersion = Space$(128)
retvalue = GetVersionExA(osinfo)
If osinfo.dwMajorVersion = 7 Then 'Windows 7
If Not Dir$(App.Path & "\xlive.dll") <> "" Then
Path = GetSpecialfolder(SpecialFolders.Local_AppData) & "\Rockstar Games\GTA IV\Settings\"
'source = path
Else
Path = GetSpecialfolder(SpecialFolders.MyDocuments) & "\Rockstar Games\GTA IV\savegames\"
'destination = path
End If
ElseIf osinfo.dwMajorVersion = 6 Then 'Vista
If Not Dir$(App.Path & "\xlive.dll") <> "" Then
Path = GetSpecialfolder(SpecialFolders.Local_AppData) & "\Rockstar Games\GTA IV\Settings\"
'source = path
Else
Path = GetSpecialfolder(SpecialFolders.MyDocuments) & "\Rockstar Games\GTA IV\savegames\"
'destination = path
End If
ElseIf osinfo.dwMajorVersion = 5 Then 'XP
If Not Dir$(App.Path & "\xlive.dll") <> "" Then
Path = GetSpecialfolder(SpecialFolders.Drives) & sUserName & "\" & GetSpecialfolder(SpecialFolders.Local_AppData) & "\Rockstar Games\GTA IV\Settings\"
'source = path
Else
Path = "C:\Users\" & sUserName & "\" & GetSpecialfolder(SpecialFolders.MyDocuments) & "Rockstar Games\GTA IV\savegames\"
'destination = path
End If
'ElseIf osinfo.dwMajorVersion = 4 Then 'Win2k etc.
Else
End If
'copy
'Delete (Path)
End Sub
I haven't configured the XP option yet but the Vista and the Windows 7 options work as expected.
Edit:
I guess to solve the source and destination problem I could place both source and destination on either side of the "else".
-
Re: Retrieve both the source and destination when they are either side of an if state
Are you testing this on all these various versions of Windows? If not, then how do you know they are correct and they work?
-
Re: Retrieve both the source and destination when they are either side of an if state
Quote:
Originally Posted by
jmsrickland
Are you testing this on all these various versions of Windows? If not, then how do you know they are correct and they work?
Of course I have tested on those versions of Windows. I have Windows 7 on my laptop and Vista on my PC. I could probably install XP on my PC if I wanted to.
-
Re: Retrieve both the source and destination when they are either side of an if state
@Night: Can you please tell me what exactly are you doing ? I mean, what you want to do. :confused:
:wave:
-
Re: Retrieve both the source and destination when they are either side of an if state
What the above code was originally designed to do was to delete the default control settings for Grand Theft Auto IV. Now, I am trying to make the program detect where the GTA IV saves are and if an additional file "xlive.dll" is in the games directory move the saves to a different location on the hard drive.
-
Re: Retrieve both the source and destination when they are either side of an if state
I may be wrong but doesn't the SHGetSpecialFolderLocation API return the proper path regardless of the OS?
Code:
Option Explicit
Private Declare Function SHGetSpecialFolderLocation Lib "Shell32.dll" (ByVal hwndOwner As Long, _
ByVal nFolder As Long, ByRef ppidl As Long) As Long
Private Declare Function SHGetPathFromIDList Lib "Shell32" (ByVal pidList As Long, ByVal lpBuffer As String) As Long
Private Declare Sub CoTaskMemFree Lib "ole32" (ByVal hMem As Long)
Const CSIDL_PERSONAL = &H5 '(user)\My Documents
Const CSIDL_LOCAL_APPDATA = &H1C '(user)\Local Settings\Application Data
Private Sub Form_Load()
MsgBox GetPath
End Sub
Private Function GetSpecialFolder(ByVal lCSIDL As Long) As String
Const S_OK As Long = 0
Const MAX_PATH As Long = 260
Dim sPath As String
Dim lIdl As Long
If SHGetSpecialFolderLocation(0, lCSIDL, lIdl) = S_OK Then
sPath = Space$(MAX_PATH)
If SHGetPathFromIDList(lIdl, sPath) Then
CoTaskMemFree lIdl
GetSpecialFolder = Left$(sPath, InStr(sPath, vbNullChar) - 1)
End If
End If
End Function
Private Function GetPath()
If Not Dir$(App.Path & "\xlive.dll") <> "" Then
GetPath = GetSpecialFolder(CSIDL_LOCAL_APPDATA) & "\Rockstar Games\GTA IV\Settings\"
Else
GetPath = GetSpecialFolder(CSIDL_PERSONAL) & "\Rockstar Games\GTA IV\savegames\"
End If
End Function
-
Re: Retrieve both the source and destination when they are either side of an if state
Quote:
Originally Posted by
MarkT
I may be wrong but doesn't the SHGetSpecialFolderLocation API return the proper path regardless of the OS?
I think there is a different method for Windows XP and before, I thought I saw a thread regarding it on the forums.
Edit:
Damn, I can't get the files to copy from one location to another. Below is the code I am using.
vb Code:
Private Sub WinVersion()
'Retrieve the current operating system and set the settings path accordingly
'http://social.msdn.microsoft.com/Forums/en/vbide/thread/395b12fd-ccfc-4281-b1b3-4c69b56f8b85
Dim osinfo As OSVERSIONINFO
Dim retvalue As Integer
Dim sNextFile As String
osinfo.dwOSVersionInfoSize = 148
osinfo.szCSDVersion = Space$(128)
retvalue = GetVersionExA(osinfo)
If osinfo.dwMajorVersion = 7 Then 'Windows 7
If Not FileExists(App.Path & "\xlive.dll") Then
source = GetSpecialfolder(SpecialFolders.Local_AppData) & "\Rockstar Games\GTA IV\"
destination = GetSpecialfolder(SpecialFolders.Local_AppData) & "\Rockstar Games\GTA IV\Settings\"
Else
source = GetSpecialfolder(SpecialFolders.Local_AppData) & "\Rockstar Games\GTA IV\Settings\"
destination = GetSpecialfolder(SpecialFolders.MyDocuments) & "\Rockstar Games\GTA IV\savegames\"
End If
ElseIf osinfo.dwMajorVersion = 6 Then 'Vista
If Not FileExists(App.Path & "\xlive.dll") Then
source = GetSpecialfolder(SpecialFolders.Local_AppData) & "\Rockstar Games\GTA IV\"
destination = GetSpecialfolder(SpecialFolders.Local_AppData) & "\Rockstar Games\GTA IV\Settings\"
Else
source = "\Rockstar Games\GTA IV\Settings\"
destination = "c:\Rockstar Games\GTA IV\savegames\"
'GetSpecialfolder(SpecialFolders.Local_AppData) &
'GetSpecialfolder(SpecialFolders.MyDocuments) &
End If
ElseIf osinfo.dwMajorVersion = 5 Then 'XP
If Not FileExists(App.Path & "\xlive.dll") Then
source = GetSpecialfolder(SpecialFolders.Local_AppData) & "\Rockstar Games\GTA IV\"
destination = GetSpecialfolder(SpecialFolders.Local_AppData) & "\Rockstar Games\GTA IV\Settings\"
Else
source = GetSpecialfolder(SpecialFolders.Local_AppData) & "\Rockstar Games\GTA IV\"
destination = GetSpecialfolder(SpecialFolders.MyDocuments) & "Rockstar Games\GTA IV\savegames\"
End If
'ElseIf osinfo.dwMajorVersion = 4 Then 'Win2k etc.
Else
End If
'Call Delete(source)
'http://www.vbforums.com/showthread.php?t=641462&highlight=copy+folder
Call VBCopyFolder(source, destination)
Call Copy(source)
End Sub
Private Sub Copy(source)
Dim c As String
c = source + "\savegames\user_e00006645743f1a9\"
sNextFile = Dir$(c + "*.*", vbNormal + vbHidden + vbReadOnly)
Do While sNextFile <> ""
SetAttr c & sNextFile, vbNormal
FileCopy c, destination
sNextFile = Dir$
Loop
End Sub
I am also using the code here.
-
Re: Retrieve both the source and destination when they are either side of an if state
Quote:
Originally Posted by
Nightwalker83
I think there is a different method for Windows XP and before, I thought I saw a thread regarding it on the forums.
The only 2 OSs I have to test against are WinXP and Win7 64bit and the SHGetSpecialFolderLocation API returns the correct path for both My Documents and the Users App Data folder.
I just don't see a need for any if statements. Just test it to see if it works.
-
Re: Retrieve both the source and destination when they are either side of an if state
Quote:
Originally Posted by
MarkT
The only 2 OSs I have to test against are WinXP and Win7 64bit and the SHGetSpecialFolderLocation API returns the correct path for both My Documents and the Users App Data folder.
I just don't see a need for any if statements. Just test it to see if it works.
Yes, thank you it worked. Now I need to test the copy method posted above and see if I can get that to work without having to hard code the paths.
Edit:
I just tested the copy method (above) using your code and for some reason it still doesn't recognize the path as being valid, although, if I hard-code the path it creates the destination folder as excepted but still does not move the files to the destination directory.
-
Re: Retrieve both the source and destination when they are either side of an if state
Any ideas on why the file copy method is not working using the code in post #31?
-
Re: Retrieve both the source and destination when they are either side of an if state
Place a breakpoint on line 48. When you reach the breakpoint check the value of c. I bet you will find a double backslash in the path.
-
Re: Retrieve both the source and destination when they are either side of an if state
Quote:
Originally Posted by
MarkT
Place a breakpoint on line 48. When you reach the breakpoint check the value of c. I bet you will find a double backslash in the path.
That doesn't appear to be the case I put a debug.print after line 48 and this was the result:
C:\Users\User\AppData\Local\Rockstar Games\GTA IV\savegames\user_e00006645743f1a9\
-
Re: Retrieve both the source and destination when they are either side of an if state
There is no file name in the path unless it's user_e00006645743f1a9 and if it is then remove the last \
-
Re: Retrieve both the source and destination when they are either side of an if state
Quote:
Originally Posted by
Nightwalker83
I think there is a different method for Windows XP and before, I thought I saw a thread regarding it on the forums.
Edit:
Damn, I can't get the files to copy from one location to another. Below is the code I am using.
vb Code:
Private Sub WinVersion()
'Retrieve the current operating system and set the settings path accordingly
'http://social.msdn.microsoft.com/Forums/en/vbide/thread/395b12fd-ccfc-4281-b1b3-4c69b56f8b85
Dim osinfo As OSVERSIONINFO
Dim retvalue As Integer
Dim sNextFile As String
osinfo.dwOSVersionInfoSize = 148
osinfo.szCSDVersion = Space$(128)
retvalue = GetVersionExA(osinfo)
If osinfo.dwMajorVersion = 7 Then 'Windows 7
If Not FileExists(App.Path & "\xlive.dll") Then
source = GetSpecialfolder(SpecialFolders.Local_AppData) & "\Rockstar Games\GTA IV\"
destination = GetSpecialfolder(SpecialFolders.Local_AppData) & "\Rockstar Games\GTA IV\Settings\"
Else
source = GetSpecialfolder(SpecialFolders.Local_AppData) & "\Rockstar Games\GTA IV\Settings\"
destination = GetSpecialfolder(SpecialFolders.MyDocuments) & "\Rockstar Games\GTA IV\savegames\"
End If
ElseIf osinfo.dwMajorVersion = 6 Then 'Vista
If Not FileExists(App.Path & "\xlive.dll") Then
source = GetSpecialfolder(SpecialFolders.Local_AppData) & "\Rockstar Games\GTA IV\"
destination = GetSpecialfolder(SpecialFolders.Local_AppData) & "\Rockstar Games\GTA IV\Settings\"
Else
source = "\Rockstar Games\GTA IV\Settings\"
destination = "c:\Rockstar Games\GTA IV\savegames\"
'GetSpecialfolder(SpecialFolders.Local_AppData) &
'GetSpecialfolder(SpecialFolders.MyDocuments) &
End If
ElseIf osinfo.dwMajorVersion = 5 Then 'XP
If Not FileExists(App.Path & "\xlive.dll") Then
source = GetSpecialfolder(SpecialFolders.Local_AppData) & "\Rockstar Games\GTA IV\"
destination = GetSpecialfolder(SpecialFolders.Local_AppData) & "\Rockstar Games\GTA IV\Settings\"
Else
source = GetSpecialfolder(SpecialFolders.Local_AppData) & "\Rockstar Games\GTA IV\"
destination = GetSpecialfolder(SpecialFolders.MyDocuments) & "Rockstar Games\GTA IV\savegames\"
End If
'ElseIf osinfo.dwMajorVersion = 4 Then 'Win2k etc.
Else
End If
'Call Delete(source)
'http://www.vbforums.com/showthread.php?t=641462&highlight=copy+folder
Call VBCopyFolder(source, destination)
Call Copy(source)
End Sub
Private Sub Copy(source)
Dim c As String
c = source + "\savegames\user_e00006645743f1a9\"
sNextFile = Dir$(c + "*.*", vbNormal + vbHidden + vbReadOnly)
Do While sNextFile <> ""
SetAttr c & sNextFile, vbNormal
FileCopy c, destination
sNextFile = Dir$
Loop
End Sub
I am also using the code
here.
Night
I did some indenting to help me follow.
Sorry if this is too obvious, but did you check to see
if source and destination have the expected
values from each of your branches?
Spoo
-
Re: Retrieve both the source and destination when they are either side of an if state
I finally managed to get the code working it moves both the folder and files as excepted.
vb Code:
Private Function GetPath()
If Not Dir$(App.Path & "\xlive.dll") <> "" Then
source = GetSpecialFolder(CSIDL_LOCAL_APPDATA) & "\Rockstar Games\GTA IV\"
destination = GetSpecialFolder(CSIDL_LOCAL_APPDATA) & "\Rockstar Games\GTA IV\"
Else
source = GetSpecialFolder(CSIDL_LOCAL_APPDATA) & "\Rockstar Games\GTA IV\"
destination = GetSpecialFolder(CSIDL_PERSONAL) & "\Rockstar Games\GTA IV\"
End If
Call Copy(source)
End Function
Private Sub Copy(source)
Dim c As String
c = source & "savegames\user_e00006645743f1a9"
destination = destination & "savegames\user_e00006645743f1a9"
Call VBCopyFolder(c, destination)
End Sub
I am using the above code in conjunction with the code I linked to in post #31.
Edit:
Quote:
Originally Posted by
Spoo
Night
I did some indenting to help me follow.
Sorry if this is too obvious, but did you check to see
if source and destination have the expected
values from each of your branches?
Spoo
Yeah, I encountered that problem and found the solution see the above code.