learning the path

dhuygu

Member
Joined
Sep 25, 2006
Messages
10
Programming Experience
Beginner
in my application I need to know the path of user's db2 program's path without asking the user. is it possible?
 
what do you mean exactly?

do you want to find the user's db location without asking the user because it's located in their windows account?
 
in my application I copy db2 tables by using db2 commands.
for export or import I need to know the directory, the path of IBM DB2 program because export command
export from C:\progra~1\IBM\DB2\SQLLIB\....
I dont want to ask the user select the directory of your IBM DB2 program.
I want to know automatically the directory of program
 
You can search for it using System.IO methods, not only the exact application name (for example db2.exe) but also parts of the path can give you indication that it is indeed the correct application file you have found. Here is code example:
VB.NET:
Private Function getDB2app() As String
  Dim myPath As String = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)
  Dim finfos() As IO.FileInfo = New IO.DirectoryInfo(myPath).GetFiles("db2.exe", IO.SearchOption.AllDirectories)
  For Each finfo As IO.FileInfo In finfos
    If finfo.Directory.Parent.Name.ToLower = "sqllib" Then Return finfo.FullName
  Next
  Return Nothing
End Function
 
Back
Top