PC Review


Reply
Thread Tools Rate Thread

changing directory to application path

 
 
dennist
Guest
Posts: n/a
 
      24th Aug 2003
I am trying to change directories in my sub main to the
application path so that my connection string will be
short - i.e. the database is in the directory with the
vbproj and forms and NOT the binary directory with the
executable. Is this possible? Or should I put the
database with the executable?

In either case I imported system.io
I tried to make sense of

System.Reflection.Assembly.GetExecutingAssembly.Location
Note The Location property returns the full path
including the file name; the Path property returned only
the path.


and I tried chdir, path.getfullpath,

etc, but no luck so far.

Frankly, vb6 was far easier to use.

dennist
 
Reply With Quote
 
 
 
 
dennist
Guest
Posts: n/a
 
      26th Aug 2003
Well, there's good news and bad news. Here's my new code
from modPrimary:

Imports System.io

Module modPrimary
Friend gstrConn As String
= "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=" 'H:\HasbaraNET\ado.net
tests\adonetTest\HasbaraSample.mdb;"




Public Sub Main()

Dim strPath As String
Dim strSubstring As String
Dim intIndexof As Integer
Dim cls1 As New Class1
strPath =
System.Reflection.Assembly.GetExecutingAssembly.Location
intIndexof = strPath.IndexOf("bin")
MsgBox(intIndexof.ToString)
strSubstring = strPath.Substring(0, intIndexof)
MsgBox(strSubstring)
'MsgBox(strPath)
'strPath = System.IO.strPath.GetDirectoryName
("adonetTest")
ChDir(strSubstring)
gstrConn = gstrConn & "HasbaraSample.mdb;"
MsgBox(gstrConn)

'indexof
'substring
'MsgBox(strPath)
'strPath = cls1.GetDirectoryName("adonetTest")
'MsgBox(strPath)

Application.Run(New frmTest1)
End Sub


End Module

Now playing with the connect string the way I do along
with
System.Reflection.Assembly.GetExecutingAssembly.Location

I get the job done in an inelegant manner.

But using all sorts of tricks with
'strPath = System.IO.strPath.GetDirectoryName
("adonetTest")

I would just get blanks, empty nulls or nothings for the
directory name. No luck there.

My solution may not be elegant, but until an elegant
solution comes along, my kludge will work just fine.

Thansk for the information

dennis
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get path do user's Application Data directory Tomas Machala Microsoft Dot NET Framework Forms 2 28th Jul 2005 07:25 PM
Changing User Directory path rebloomfield@msn.com Microsoft Windows 2000 Active Directory 2 25th Aug 2004 11:03 PM
Application.Path (Getting the directory that my workbook is in) Richard1284 Microsoft Excel Programming 1 25th May 2004 01:56 PM
Changing Application name and Virtual Directory name Santosh Pradhan Microsoft Dot NET 0 25th Mar 2004 03:18 PM
Setting Application directory as path for database. M K Microsoft Dot NET Framework Forms 1 10th Jul 2003 04:53 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:50 AM.