|
-
Feb 24th, 2013, 05:25 AM
#1
Thread Starter
Lively Member
How to define If string contains something.
By the title you may be thinking of .Contains. But that will not work here. I need to define If the Path that I have leads to .Ink or directly to .Exe file. If I try Path.Contains(".Ink"), It wont work because it takes the name of the file and ads .Ink at the end. Example:
Code:
Path = "C:\Application.Ink"
If Path.Contains(".Ink") Then
Code...
End If
But this wont work, and I know why, but I dont know any other command how to do it.
Please help.
-
Feb 24th, 2013, 05:35 AM
#2
Lively Member
Re: How to define If string contains something.
-
Feb 24th, 2013, 05:36 AM
#3
Re: How to define If string contains something.
I don't understand your explanation, sorry. However, while you wait for more replies, the file extension is probably wrong. If you're after the extension for a shortcut, it is "lnk" ie, the first, third and fourth letters of the word "link". You have used capital i instead of lower case l.
-
Feb 24th, 2013, 05:47 AM
#4
Thread Starter
Lively Member
Re: How to define If string contains something.
Ok, So what I need is to tell the application when the path is leading to .exe or .ink (Shortcut).
-
Feb 24th, 2013, 05:53 AM
#5
Re: How to define If string contains something.
 Originally Posted by FireDust
Ok, So what I need is to tell the application when the path is leading to .exe or .ink (Shortcut).
If you want to know what the file extension is then try, IO.Path.GetExtension(). And I'm guessing you actually mean "LNK" not "INK"?
Code:
Dim filePath = "C:\Application.Lnk"
' get file extension of path in upper case
Dim fileExtension = IO.Path.GetExtension(filePath).ToUpper
' compare
If fileExtension = ".LNK" Then ' shorcut link
Debug.WriteLine("Link file")
ElseIf fileExtension = ".EXE" Then 'executable
Debug.WriteLine("Executable file")
End If
Last edited by Edgemeal; Feb 24th, 2013 at 06:06 AM.
-
Feb 24th, 2013, 05:57 AM
#6
Thread Starter
Lively Member
Re: How to define If string contains something.
Yea, sorry. :P
But thanks for the answer. Really helped me alot.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|