CD Menu
CD Menu
CD Menu
CD Menu
CD Menu
CD Menu CD Menu CD Menu CD Menu CD Menu CD Menu CD Menu CD Menu
CD Menu CD Menu
CD Menu
Go Back  Xtreme Visual Basic Talk > > > CD Menu


Reply
 
Thread Tools Display Modes
  #1  
Old 07-02-2008, 07:44 AM
Copeland Copeland is offline
Newcomer
 
Join Date: Apr 2008
Posts: 6
Default CD Menu


This isn't an installation question exactly but.....

I have several folders on CD that up until now I have had to access "manually" and what I want to do is create a menu for the CD whereby when I click on the relevant button it accesses the relevant folder and the relevant application.

I'm pretty much there except for the clever bit of actually accessing the pathname, for example.....

When clicking on a button marked "Happy", the "Happy" program will be accessed via the path E:\Emotions Folder\Happy.exe

Can someone tell me how I actually do this. Bearing in mind that not all CD drives are E: and so the command needs to access the CD regardless of which drive letter it is.

I am using VB 2008 Express Edition.

Many thanks
Reply With Quote
  #2  
Old 07-02-2008, 08:01 AM
AtmaWeapon's Avatar
AtmaWeaponCD Menu AtmaWeapon is offline
Fabulous Florist

Forum Leader
* Guru *
 
Join Date: Feb 2004
Location: Austin, TX
Posts: 9,500
Default

The Application.StartupPath property indicates the location from which the application started. The drive is going to be the first part of that path.

It also appears that the Path.GetRoot method might be useful for getting the drive from the path, but it looks kind of wonky so I don't know how far I'd trust it.
__________________
.NET Resources
My FAQ threads | Tutor's Corner | Code Library
I would bet money 2/3 of .NET questions are already answered in one of these three places.
Reply With Quote
  #3  
Old 07-02-2008, 10:18 AM
Copeland Copeland is offline
Newcomer
 
Join Date: Apr 2008
Posts: 6
Default

Okay, so I worked out that I can use

Shell ("E:\Emotions Folder\Happy.exe")

This would be fine if it was always E: but it's not, so now I need to know how to account for different drive paths.
Reply With Quote
  #4  
Old 07-02-2008, 11:11 AM
darkforcesjedi's Avatar
darkforcesjediCD Menu darkforcesjedi is offline
Trust me, I'm an

* Expert *
 
Join Date: Apr 2001
Location: In ur base, pwnin d00dz
Posts: 1,964
Default

To list CD-ROM drives:

Code:
Imports System.IO Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load For Each DI As DriveInfo In DriveInfo.GetDrives If DI.DriveType = DriveType.CDRom Then Debug.WriteLine(DI.Name) End If Next End Sub End Class
__________________
To err is human; to debug, divine.
Reply With Quote
  #5  
Old 07-02-2008, 01:26 PM
AtmaWeapon's Avatar
AtmaWeaponCD Menu AtmaWeapon is offline
Fabulous Florist

Forum Leader
* Guru *
 
Join Date: Feb 2004
Location: Austin, TX
Posts: 9,500
Default

Quote:
Originally Posted by Copeland View Post
Okay, so I worked out that I can use

Shell ("E:\Emotions Folder\Happy.exe")

This would be fine if it was always E: but it's not, so now I need to know how to account for different drive paths.
Did you read my post at all? Let's look at the facts.

Let's say your program is at "E:\Autorun.exe". If you check the Application.StartupPath property, you'll get a string with the value "E:\Autorun.exe" back. If you look very carefully, you'll notice that the drive letter is at the front of that path. In fact, if you can always guarantee it's a drive, you can pretty much assume the first three characters of the path are the drive letter. So, all you have to do is get these three characters and store them in a string variable*. Let's call it drivePath.

Now, you know that you need to specify a path in the form "<drive letter>:\Emotions Folder\Happy.exe". You have the drive letter part in drivePath. You know that the part that goes on the end is "Emotions Folder\Happy.exe". You could just mash them together, but there's a better way.

Now, a kind of obscure but helpful class is System.IO.Path; this class lets you manipulate paths in a pretty easy manner. In particular it helps out because it handles the mess of figuring out how many backslashes to put in for you. So, since you have drivePath and the path to the file you want, you can make a full path easily:
Path.Combine(drivePath, "Emotions Folder\Happy.exe")

* I'm not providing a code sample for this on purpose. Your lack of acknowledgement of my post leads me to believe you want something you can paste into your application, and I refuse..
__________________
.NET Resources
My FAQ threads | Tutor's Corner | Code Library
I would bet money 2/3 of .NET questions are already answered in one of these three places.
Reply With Quote
  #6  
Old 07-02-2008, 01:45 PM
darkforcesjedi's Avatar
darkforcesjediCD Menu darkforcesjedi is offline
Trust me, I'm an

* Expert *
 
Join Date: Apr 2001
Location: In ur base, pwnin d00dz
Posts: 1,964
Default

He never said the calling application was on the CD.

If it is on the CD, then I agree Application.StartupPath is the best option.

If it is not on the CD, the best option is likely to enumerate the CD drives and check for the file on each.
__________________
To err is human; to debug, divine.
Reply With Quote
  #7  
Old 07-02-2008, 02:29 PM
Copeland Copeland is offline
Newcomer
 
Join Date: Apr 2008
Posts: 6
Default

AtmaWeapon,

Yes, I did read your reply and I am grateful but I am a little out of my depth and I am just getting to grips with this. I am afraid that I do not understand how I use Application.StartupPath and would appreciate further help on this.
Reply With Quote
  #8  
Old 07-02-2008, 03:02 PM
AtmaWeapon's Avatar
AtmaWeaponCD Menu AtmaWeapon is offline
Fabulous Florist

Forum Leader
* Guru *
 
Join Date: Feb 2004
Location: Austin, TX
Posts: 9,500
Default

It's a property. You assign it to a variable by typing the variable name followed by an equals sign and the property name.
Code:
Dim startupPath as String = Application.StartupPath
Now, if only there were some method that would help you pull the first 3 characters of that string out... one could almost call that string a substring since it's a smaller part of the large string...
__________________
.NET Resources
My FAQ threads | Tutor's Corner | Code Library
I would bet money 2/3 of .NET questions are already answered in one of these three places.
Reply With Quote
  #9  
Old 07-03-2008, 03:10 PM
cugone cugone is offline
Centurion
 
Join Date: Nov 2007
Posts: 160
Default

Wouldn't a /much/ simpler solution be to generation an XML "setup" file (akin to the .ini files of the past) upon installation that stores the users CD-ROM drive letter and any other pertinent paths? I seem to remember many, many applications doing this so they have a reference immediately where everything is stored.
Reply With Quote
  #10  
Old 07-03-2008, 09:28 PM
AtmaWeapon's Avatar
AtmaWeaponCD Menu AtmaWeapon is offline
Fabulous Florist

Forum Leader
* Guru *
 
Join Date: Feb 2004
Location: Austin, TX
Posts: 9,500
Default

There's a few problems with that.
  • Where do you store the files? Obviously, if the program is intended to run from a CD, the user wanted to have a minimal impact on the user's machine. The only logical place is the user's application data directory, but some people might be suspicious that this CD wants to create files on their hard drive.
  • What happens if the user has multiple CD drives? You'll record the one that the CD was first placed in. Now what happens when the user puts the CD in a different drive? "Please insert the disc in the drive." "***? The disc IS in the drive!"
  • The question asks, "How do I determine what drive has the CD?" Your solution is to store the drive letter in a file. That's great, how do you find the drive letter so you can save it? Your solution solves a different problem, and requires a solution to the OP's problem first.
__________________
.NET Resources
My FAQ threads | Tutor's Corner | Code Library
I would bet money 2/3 of .NET questions are already answered in one of these three places.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
CD Menu
CD Menu
CD Menu CD Menu
CD Menu
CD Menu
CD Menu CD Menu CD Menu CD Menu CD Menu CD Menu CD Menu
CD Menu
CD Menu
 
CD Menu
CD Menu
 
-->