| |

VerySource

 Forgot password?
 Register
Search
View: 796|Reply: 5

Obtaining the relative path

[Copy link]

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 Invalid IP Address

Post time: 2020-3-10 02:00:01
| Show all posts |Read mode
Absolute paths are now available, such as:
 e:\code\data\model\man\
Already file name
   a.txt

I want to get now
 \data\model\man\a.txt
How to do it?
Reply

Use magic Report

0

Threads

8

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-6-1 19:15:01
| Show all posts
Isn't it just string interception? Remove the non-absolute part?
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-6-2 18:30:01
| Show all posts
CSring a,b;
   a= "e\code\data\model\man\"
   b=a.Mid(7); or b=a.left(7);
 Anyway, you will come out with some functions after writing a.
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 Invalid IP Address

 Author| Post time: 2020-6-3 14:15:01
| Show all posts
The problem is that what I want to get is the content behind data\
Not with numbers
Reply

Use magic Report

0

Threads

45

Posts

32.00

Credits

Newbie

Rank: 1

Credits
32.00

 China

Post time: 2020-6-3 23:45:01
| Show all posts
CString a,b;
   a = "C:\\A\\B\\C\\D\\a.txt";
   b = "C:\\A\\E\\C\\D\\";

If the current directory is b, to get the relative path of a.txt, you can't directly use the string above...
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 Invalid IP Address

 Author| Post time: 2020-6-8 23:45:01
| Show all posts
Solved it myself, using the method of comparing lengths
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list