Point me in the right direction  
Author Message
Learning VB





PostPosted: Visual Basic Express Edition, Point me in the right direction Top

I am wondering where i can get more specific information on the use of Me.Text  = Filename.

 

I can get it to work but it gives me the full path of the file.  I am sure that there is some factor that I can attach to the above to only display the filename without seeing the whole path and show only the name of the file.

 The problem is I don't know if it is a Me issue or a FileName. issue.

I have scoured (at least in my mind) several books, and the MSDN and I am not finding what I am looking for.  I am sure it is also very, very basic.

Anyone

LDavis 501

 



Visual Studio Express Editions31  
 
 
ahmedilyas





PostPosted: Visual Basic Express Edition, Point me in the right direction Top

Well, what is the value of "Filename"

 

if the value if filename is something like:

C:\someFolder\anotherFolder\filename.txt

then well, thats the problem. In this case, to get the filename only:

Me.Text = fileName.SubString(filename.LastIndexOf("\"))

This will get all the text after the last backslash, just the filename.

 

hope it helps!



 
 
Tall Dude





PostPosted: Visual Basic Express Edition, Point me in the right direction Top

Me.Text = Path.GetFileNameWithoutExtension(FilePath)



 
 
LDavis501





PostPosted: Visual Basic Express Edition, Point me in the right direction Top

Ahmedilyas, yours does indeed work but leaves the following: \textname.extension....Not quite what I was looking for.

Talldude, you hit it dead on the nail. Now can you put me to how you did it Where could I look to get a better handle on this

Thanks,

LDavis501


 
 
LDavis501





PostPosted: Visual Basic Express Edition, Point me in the right direction Top

Talldude,

Nevermind. I looked up the Path.Class and found what I was looking for. Thanks for the help. Man, I wish I knew all the ins and outs of this....but then again I justed started the whole learning programming less then 2 weeks ago...and I mean absolutely started, never programmed before then.

Ah well.....More time is more learning.

Thanks,

LDavis501


 
 
ahmedilyas





PostPosted: Visual Basic Express Edition, Point me in the right direction Top

cool, glad someone nailed it ;) My mistake was to add 1 to the index.

"under the bonnet" - this is what Path.GetFileNameWithoutExtension does ;-)



 
 
LDavis501





PostPosted: Visual Basic Express Edition, Point me in the right direction Top

Is it just me or am I not getting this, and if I am not getting it, where can I go to learn more.

This was such a basic, noob question, but the problem is this I didn't even now where to look for it, as in Accessing Folders and Files.

I guess all I can do is trudge on and hope that you all helping me and other noobs will finally gel at some point.


 
 
ahmedilyas





PostPosted: Visual Basic Express Edition, Point me in the right direction Top

Everybody learns from some place, internet, books, asking questions etc..

the great resource you will ever need is as follows:

1) MSDN forums

2) the big MSDN documentation library which is installed on your machine or on http://msdn.microsoft.com

its about experimenting, learning, teaching yourself - don't worry, you will get there ;-)



 
 
LDavis501





PostPosted: Visual Basic Express Edition, Point me in the right direction Top

Thanks for the encouragement.

Man I am always scouring the MSDN for my anwsers, the problem tends to be not knowing the right question to ask myself....ya know....

Now if I could only get that darn Save Function to work with a textbox instead of the RichTextBox SaveFile.


 
 
Tall Dude





PostPosted: Visual Basic Express Edition, Point me in the right direction Top

To save a textbox, see, in your index help in Visual Basic:

'StreamWriter class, walkthroughs'