Locating a file

  • Thread starter Thread starter CD Tom
  • Start date Start date
C

CD Tom

I have a backup that creates .txt files that I use to restore tables if
something goes wrong. Before I restore a table I want to be sure that the
..txt file is located where it was backed up to. In the backup I use the
BrowseForFolderByPath command and pick the drive, directory and folder where
I want to place the .txt file. I was using the fReturnFilePath command to
locate the .txt file and that was working great until Vista came along. I've
tested my code on a Vista machine I have and it worked ok, when I send it to
another person using Vista it doesn't work. I have a message that displays
saying there is not file to restore. If this isn't clear let me know and
I'll try again. Thanks for any help.
 
As far as I'm aware, there's no issue with BrowseForFolderByPath under
Vista.

Remember, though, that Vista has a far more stringent security model. Are
you sure that the user has the necessary permissions on the file and folder?
 
Yes, he is setup as administrator. We've tried different things, I made sure
that the program was running as administrator, I even tried turning off the
UAC, nothing worked. Like I mentioned I tested it on my machine and it
worked fine, his settings in Vista are the same. Is there another way to
locate a file that I might try?
 
I hope this is what your looking for.
Public Function BrowseForFolderByPath(sSelPath As String) As String

Dim BI As BROWSEINFO
Dim pidl As Long
Dim lpSelPath As Long
Dim spath As String * MAX_PATH

With BI
.hOwner = Me.hwnd
.pidlRoot = 0
If Vbktitle = 1 Then
.lpszTitle = "Select folder to use for Backup."
Else
.lpszTitle = "Select folder to use for Restore."
End If
.lpfn = FARPROCl(AddressOf BrowseCallbackProcStr)

lpSelPath = LocalAlloc(LPTR, Len(sSelPath) + 1)
CopyMemory ByVal lpSelPath, ByVal sSelPath, Len(sSelPath) + 1
.lparam = lpSelPath
.ulFlags = BIF_RETURNONLYSDIRS Or BIF_NEWDIALOGSTYLE

End With

pidl = SHBrowseForFolder(BI)
If pidl = 0 Then
spath = ""
End If
If pidl Then

If SHGetPathFromIDList(pidl, spath) Then
BrowseForFolderByPath = left$(spath, InStr(spath, vbNullChar) - 1)
End If

Call CoTaskMemFree(pidl)

End If

Call LocalFree(lpSelPath)

End Function
 
Back
Top