|
Much easier
add
using System.IO;
to the top of your file
Then you can use
<br />
string strFile = @"c:\file\file.txt";<br />
string strTemp = Path.GetFileName(strFile);
strTemp = Path.GetDirectoryName(strFile);
strTemp = Path.GetPathRoot(strFile);
Problem with the earlier suggestion is that it won't help with more than a single directory - you can't gaurantee that item 3 in the array will be the filename every time, because one more layer such as
c:\somedir\somsubdir\somefile.txt
will force the filename into the 4th spot - at least using Path functions you can always get the Drive, Actual Directory and Actual file....
After that you can put them into an array
Mark.
-- modified at 0:03 Wednesday 18th April, 2007
|
|
|
|
|
Mark Greenwood wrote: you can't gaurantee that item 3 in the array will be the filename every
No, but you can use the array length to work that out, and you can move one step at a time, too. I'd use the System.IO methods, having said that. They are just more self documenting.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi, u can use the split method of the string and pass the "/" as the parameter, this will return u an array as u wish to have...
Thanks & Regards,
Pramod
"Everyone is a genius at least once a year"
|
|
|
|
|
Everybody can show me the way can add a Form to TabControl in other form in C#.NET 2005? I'm a beginner. Thank you very much!
|
|
|
|
|
Maybe you meant that you want to add a tab panel?
Just find propety 'TabPages' in properties list. Click the button '...' beside, and then add more taps in dialog tabpage collections editor.
Have funs.
LC
|
|
|
|
|
Thanks your answer. But I designed a window form and now I creat a new window form has a TabControl. And I want to add fist form to this TabControl. How do I make its? Thanks!
-- modified at 23:24 Tuesday 17th April, 2007
|
|
|
|
|
Hello,
This is just not possible.
You can add a TpPage to the TabPages property of the TabControl (As someone said before).
Instead of your self designed Form you should design a UserControl and add this on one of the TabPages.
All the best,
Martin
|
|
|
|
|
It is possible but you must use non-microsoft controls (for example Infragistics has control for that). You must override ms tabcontrol and implement it. I have my overriden tabconrol if you want source just give me your email to send it. I'm now at work but when go back at home i will send it code.
Greetings,
Svetlin Ralchev
.NET Software Developer
InterConsult Bulgaria Ltd.
www.icb.bg
Return to innocence
|
|
|
|
|
Thanks but no need for that.
My answer was based on the fact that he whants to use standard MS controls.
All the best,
Martin
|
|
|
|
|
Hi,
I'm writing a program to monitor processes in computer. I used class Process in namespace System.Diagnostics. But it seems there no information about the parent process of a process such as id or process_name in this class. So, if i want to know information about the parent process of a process (or child processes of a process), how must i do?
LC
|
|
|
|
|
You can't find it because this relationship doesn't exist. Process cannot have child processes, at least not at the O/S level. A process can launch another process and treat it as a child, but the O/S doesn't recognize the significance.
You can, however, have multiple processes running under the same job object though, so the processes can be managed as a unit. But, that in no way means that every process is running under a job object. A process can be created without a job!
There is no support in the .NET Framework BCL for jobs though, so you'd have to go directly to the Win32 API to enumerate the processes under each job.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
Thanks for your answer. I'll use another way (API, as you suggested, maybe)
|
|
|
|
|
Hi, I'm wondering if it's possible at all to detect whether the user has clicked the up or the down button specifically.
Thanks
|
|
|
|
|
I think you can't................
My small attempt...
|
|
|
|
|
Get the keycode of the Key and
Compare it with the UP and Down button Keycode
karthick
|
|
|
|
|
Hey All,
How to collect the Objects? Like an array, how do we collect the objects?
|
|
|
|
|
Do you mean an ArrayList ? Or are you using C# 2.0, then List<object> will do. Replace object with whatever class you want to collect.
This is the sort of question that's bound to be covered by a beginners book, I recommend working through a book if you're serious about learning C#.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
You can use ArrayList..............
Just declare like ArrayList objArrayList = new ArrayList();
Them you can add the objects
objArrayList.Add(obj);
My small attempt...
|
|
|
|
|
Hey All,
Thank you very much for your kind help.
so my question is, hwo could i store the objects of a table(which contains 2 columns and 170 rows) in an arrayList?
-- modified at 12:19 Wednesday 18th April, 2007
|
|
|
|
|
You mean you are having objects on each cell...
try the foreach method to retrieve all from that. then use arraylist
foreach(Datarow row from table.rows
{
objarrayList.Add(row["item"];
}
My small attempt...
|
|
|
|
|
Is there a legitimate syntax for declaring a generic class taking multiple generic parameters, specifying constraints on *each* parameter? For instance, VS2005 will not complain about multiple constraint parameters and a *singular* constraint (where) expression:
public class MyGeneric<T1, T2> : Component where T1 : Class1
{
}
But it doesn't want to see the following:
public class MyGeneric<T1, T2> : Component where T1 : Class1, where T2 : Class2
{
}
Does anybody know the syntax for multiple generic constraints?
TIA,
m
|
|
|
|
|
Just omit the comma:
public class MyGeneric<t1, t2=""> : Component where T1 : Class1 where T2 : Class2
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C# to C++ converter, VB to C++ converter
Instant Python: C# to Python converter, VB to Python converter
|
|
|
|
|
Wow, thanks!
Funny, you have to comma delimit the new constraint after another constraint...
public class MyCollection<T1, T2> : Component where T1: MyClass1, new() where T2 : MyClass2
...but not the where of the subsequent constraint?
Sure does work. I appreciate the tip.
m
|
|
|
|
|
I have a database application that has a datatable bound to both a DataGridView and some text boxes. The text boxes, collectively, show one row of data. Now, if a user has edited a row and clicks 'Save' in the File menu, I want those changes to be saved. Right now, I'm basing the decision to save or not save a row on whether the DataRowState for that row is 'Modified'. But, if the row the user has edited still has the 'focus', so to speak, the DataRowState is not 'Modified', but 'Unchanged', even if the individual values in the text boxes (to which the data table is bound) have been changed. As soon as I go view another row in the database, though, the DataRowState becomes 'Modified'. Is there an easy way to validate the row without leaving it?
|
|
|
|
|
Just a guess, but you might try calling the EndEdit method on the DataRow prior to checking its DataRowState.
|
|
|
|