7 Replies - 259 Views - Last Post: 24 June 2012 - 08:35 AM Rate Topic: -----

#1 k3nnt0ter0  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 181
  • Joined: 16-January 10

Coding a File Location

Posted 24 June 2012 - 06:07 AM

How am I going to make this code search for the path of the file without placing its whole path.

Like this one
data source=..\invsysdb.mdb

it is searching for the database on the entire Project Folder.

I would like for it to be like at the code shown above so that there would be no error even I change its location. Here's the code.
pbTBoxOff.BackgroundImage = New Bitmap("C:\Users\Kenn\Desktop\cheber\pressIMG.png")


Is This A Good Question/Topic? 0
  • +

Replies To: Coding a File Location

#2 m_wylie85  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 93
  • View blog
  • Posts: 871
  • Joined: 15-October 10

Re: Coding a File Location

Posted 24 June 2012 - 06:21 AM

Have a look at this :

http://msdn.microsof...irectories.aspx
Was This Post Helpful? 0
  • +
  • -

#3 k3nnt0ter0  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 181
  • Joined: 16-January 10

Re: Coding a File Location

Posted 24 June 2012 - 06:41 AM

I didn't get it.
Was This Post Helpful? 0
  • +
  • -

#4 m_wylie85  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 93
  • View blog
  • Posts: 871
  • Joined: 15-October 10

Re: Coding a File Location

Posted 24 June 2012 - 07:12 AM

What did you not get?
Was This Post Helpful? 0
  • +
  • -

#5 k3nnt0ter0  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 181
  • Joined: 16-January 10

Re: Coding a File Location

Posted 24 June 2012 - 07:25 AM

I didn't get how to do it.
Was This Post Helpful? 0
  • +
  • -

#6 m_wylie85  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 93
  • View blog
  • Posts: 871
  • Joined: 15-October 10

Re: Coding a File Location

Posted 24 June 2012 - 07:39 AM

Ok no problem

This is your directory to your desk top:

"C:\Users\Kenn\Desktop\cheber\pressIMG.png"

OK but say you install your program on someone else's computer their desktop directory will not be the same, This is were special directories helps.So say you need to get pressIMG.png from any computers desktop directory you could use the below code, This is because the special directory does not care about (\Users\Kenn) it basic just finds the desktop on any computer and looks for the file. This can be done with a variety of folders it does not have to be the desk top.

data source= CStr(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) & "\pressIMG.png")


That code is not checked but should help explain what i was talking about

This post has been edited by m_wylie85: 24 June 2012 - 07:41 AM

Was This Post Helpful? 0
  • +
  • -

#7 k3nnt0ter0  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 181
  • Joined: 16-January 10

Re: Coding a File Location

Posted 24 June 2012 - 08:05 AM

May I ask what is the use of CStr there?
and does the file has to be enclosed with double quotation and also with back slash?
Was This Post Helpful? 0
  • +
  • -

#8 m_wylie85  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 93
  • View blog
  • Posts: 871
  • Joined: 15-October 10

Re: Coding a File Location

Posted 24 June 2012 - 08:35 AM

All Cstr does is converts to string. Google it for a better explication; And yes The File Name needs to be 'double quotation and also with back slash' but don't just take my word for it take out the things that your curious about see what happens if you do use them by using a break point this will help you debug and find errors in the further.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1