How to remove .extension from a System.IO.FileInfo file ?

G

gamesforums

How can i remove the .sql extension from my script files?? I want to
read all scripts in directory into a hashtable, and use
Right(scriptFile.FullName, 3) as my key and full name as value:

'buildscript_001.sql
'buildscript_002.sql

'Want to have 001 as key and buildscript_001.sql as value.


Dim scriptDirectory As New IO.DirectoryInfo "C:\Applications
\MyApplicationMainline\SW\App\DatabaseScripts\BuildScripts\")

Dim scriptFileList As IO.FileInfo() =
scriptDirectory.GetFiles()
Dim scriptFile As IO.FileInfo
Dim scriptFileTable As New Hashtable

For Each scriptFile In scriptFileList
'Read scripts to Hash tbl..
scriptFileTable.Add(Right(scriptFile.FullName, 3),
scriptFile.FullName)
Next

Regards
Mcad
 
R

RB

How can i remove the .sql extension from my script files?? I want to
read all scripts in directory into a hashtable, and use
Right(scriptFile.FullName, 3) as my key and full name as value:

'buildscript_001.sql
'buildscript_002.sql

'Want to have 001 as key and buildscript_001.sql as value.


Dim scriptDirectory As New IO.DirectoryInfo "C:\Applications
\MyApplicationMainline\SW\App\DatabaseScripts\BuildScripts\")

Dim scriptFileList As IO.FileInfo() =
scriptDirectory.GetFiles()
Dim scriptFile As IO.FileInfo
Dim scriptFileTable As New Hashtable

For Each scriptFile In scriptFileList
'Read scripts to Hash tbl..
scriptFileTable.Add(Right(scriptFile.FullName, 3),
scriptFile.FullName)
Next

Regards
Mcad

Check here:
http://msdn2.microsoft.com/en-us/library/system.io.path_members.aspx

Particularly look at GetFileNameWithoutExtension :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,007
Latest member
obedient dusk

Latest Threads

Top