Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


File directory

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
ScStyLe
How do I cheat?
Reputation: 0

Joined: 07 May 2010
Posts: 6

PostPosted: Mon Nov 01, 2010 12:03 pm    Post subject: File directory Reply with quote

example:"C:/program files/aaa/abc/axd.txt"

i want this directory but only this "abc/axd.txt" part how can i do this?

please help


VB.net
Back to top
View user's profile Send private message
HomerSexual
Grandmaster Cheater Supreme
Reputation: 5

Joined: 03 Feb 2007
Posts: 1657

PostPosted: Mon Nov 01, 2010 12:11 pm    Post subject: Reply with quote

it would help if we knew where the program was running from. Is it running from directory ../abc or from ../aaa
_________________
Back to top
View user's profile Send private message
ScStyLe
How do I cheat?
Reputation: 0

Joined: 07 May 2010
Posts: 6

PostPosted: Mon Nov 01, 2010 12:54 pm    Post subject: Reply with quote

but i want do this with open file dialog
Back to top
View user's profile Send private message
AhMunRa
Grandmaster Cheater Supreme
Reputation: 27

Joined: 06 Aug 2010
Posts: 1117

PostPosted: Mon Nov 01, 2010 2:53 pm    Post subject: Reply with quote

In C#

Code:

string myStr = "c:\mydir\abc\abc.txt";

string[] arrStr = new string[4];

char[] sep = {'\'};

arrStr = myStr.Split(sep);

for(int x = 0; x < arrStr.Length; x++ )
{
     if( x == arrStr.Length - 1 || x == arrStr.Length )
          Response.Write(arrStr[x].ToString());
}


Will loop through and return the last 2 elements of your array. Not the most elegant solution.

_________________
<Wiccaan> Bah that was supposed to say 'not saying its dead' lol. Fixing >.>
Back to top
View user's profile Send private message
Deltron Z
Expert Cheater
Reputation: 1

Joined: 14 Jun 2009
Posts: 164

PostPosted: Mon Nov 01, 2010 6:09 pm    Post subject: Reply with quote

A shorter solution would be:
string Str = "a/b/c/d.txt";
int Index = Str.LastIndexOf('/') + 1;
Console.WriteLine(Str.Substring(Index, Str.Length - Index));
Back to top
View user's profile Send private message
Jani
Grandmaster Cheater
Reputation: 2

Joined: 29 Dec 2006
Posts: 804

PostPosted: Tue Nov 02, 2010 12:45 pm    Post subject: Reply with quote

Deltron Z wrote:
A shorter solution would be:
This doesn't return "abc/axd.txt", does it?

Since no one is using the requested language, I'll post mine too! C++ with MOC magic:
Code:
QFileInfo f("C:/program files/aaa/abc/axd.txt");
QString s = f.absoluteDir().dirName() + '/' + f.fileName();
// s is now "abc/axd.txt"
Or, if you want to handle it as a string:
Code:
QString s("C:/program files/aaa/abc/axd.txt");
s.remove(QRegExp(".*/(?=.*/)"));
// s is now "abc/axd.txt"
Inverse QString::section() would be cool, but too bad there isn't one.
Back to top
View user's profile Send private message
ScStyLe
How do I cheat?
Reputation: 0

Joined: 07 May 2010
Posts: 6

PostPosted: Tue Nov 02, 2010 2:36 pm    Post subject: Reply with quote

but i need do this with vb.net
Back to top
View user's profile Send private message
AhMunRa
Grandmaster Cheater Supreme
Reputation: 27

Joined: 06 Aug 2010
Posts: 1117

PostPosted: Tue Nov 02, 2010 3:20 pm    Post subject: Reply with quote

Couldn't tell you how in VB, I've always hated that language. You could still do it in either C# or C++ using MS Visual C# or MS Visual C++ and still make use of the .NET roll up.
_________________
<Wiccaan> Bah that was supposed to say 'not saying its dead' lol. Fixing >.>
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites