.NET Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgramming.NET Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old January 13th, 2005, 03:03 PM
jimanny jimanny is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 2 jimanny User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
VB.NET code to find path of file in system PATH?

Hello,

I am looking for a way to get the full path of a file that is in the system path environment variable using VB.NET. For example like in the FOR command in DOS:

%~$PATH:I - searches the directories listed in the PATH
environment variable and expands %I to the
fully qualified name of the first one found.
If the environment variable name is not
defined or the file is not found by the
search, then this modifier expands to the
empty string

Would it use System.IO.Path somehow?

Thanks

Reply With Quote
  #2  
Old January 13th, 2005, 07:22 PM
jimanny jimanny is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 2 jimanny User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I've been looking for an existing function in the framework that would do this but could not find one. So here's what I have instead:

Code:
 
Private paths() As String = Split(Environment.GetEnvironmentVariable("PATH"), ";")
Private messageOutput As String
Private fileInPath as String = "notepad.exe"  ' for example
 
For Each pathItem In paths
	 If File.Exists(pathItem & "\" & fileInPath) Then
		  messageOutput += pathItem & vbCrLf
	 End If
Next
 
Msg(messageOutput)


Not too bad but is there a better way?

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgramming.NET Development > VB.NET code to find path of file in system PATH?


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap