Strings

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi I have the following vb6 code that I need to convert to c#

strDBPath = Left(strDBPath, InStrRev(strDBPath, "\"))

Thus if I pass in
C:\Test 5\Taster.mdb

the output should be
C:\Test 5

I've tried String.LastIndexOf and String.Substring but can't seem to get
them to work.
 
Hi,

If you want to get the name of parent directory you can try:

string parentDirectoryName=new FileInfo(filePath).DirectoryName;

HTH
Marcin
 
Hello jez123456,
Hi I have the following vb6 code that I need to convert to c#

strDBPath = Left(strDBPath, InStrRev(strDBPath, "\"))

Thus if I pass in C:\Test 5\Taster.mdb

the output should be
C:\Test 5

Dim path As String = Path.GetDirectoryName(strDBPath)
 
Back
Top