473,471 Members | 1,716 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Strings

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.
Nov 16 '05 #1
4 1735
It's ok, I sorted with

strDBPath = tmp.Substring(0,strDBPath.LastIndexOf(@"\"))

"jez123456" wrote:
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.

Nov 16 '05 #2
Hi,

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

string parentDirectoryName=new FileInfo(filePath).DirectoryName;

HTH
Marcin
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.

Nov 16 '05 #3
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)

--
Lasse Vågsæther Karlsen
http://www.vkarlsen.no/
mailto:la***@vkarlsen.no
PGP KeyID: 0x0270466B
Nov 16 '05 #4
Jez,

In addition to all other answers this link.

http://msdn.microsoft.com/library/de...mberstopic.asp

dotNet is much more powerfull than VB6

I hope it helps,

Cor
Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
by: Ravi | last post by:
Hi, I have about 200GB of data that I need to go through and extract the common first part of a line. Something like this. >>>a = "abcdefghijklmnopqrstuvwxyz" >>>b = "abcdefghijklmnopBHLHT"...
17
by: Gordon Airport | last post by:
Has anyone suggested introducing a mutable string type (yes, of course) and distinguishing them from standard strings by the quote type - single or double? As far as I know ' and " are currently...
16
by: Paul Prescod | last post by:
I skimmed the tutorial and something alarmed me. "Strings are a powerful data type in Prothon. Unlike many languages, they can be of unlimited size (constrained only by memory size) and can hold...
4
by: agent349 | last post by:
First off, I know arrays can't be compared directly (ie: if (arrary1 == array2)). However, I've been trying to compare two arrays using pointers with no success. Basically, I want to take three...
25
by: Rainmaker | last post by:
Hi, Can anyone tell me an efficient algorithm to sort an array of strings? Keep in mind that this array is HUGE and so the algorithm should me efficient enough to deal with it. Thanks
6
by: Broeisi | last post by:
Hello, I wrote the tiny progam below just to understand arrays and strings better. I have 2 questions about arrays and strings in C. 1. Why is it that when you want to assign a string to an...
2
by: Potiuper | last post by:
Question: Is it possible to use a char pointer array ( char *<name> ) to read an array of strings from a file in C? Given: code is written in ANSI C; I know the exact nature of the strings to be...
19
by: pkirk25 | last post by:
I wonder if anyone has time to write a small example program based on this data or to critique my own effort? A file called Realm List.html contains the following data: Bladefist-Horde...
95
by: hstagni | last post by:
Where can I find a library to created text-based windows applications? Im looking for a library that can make windows and buttons inside console.. Many old apps were make like this, i guess ...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.