|
It would help if you told us what exactly are you having problems with...
The process itself is fairly straightforward, if you know how to use recursion.
You create a function where you have a directory and a TreeNode as parameter, let's say
void AddDirectoryNodes(TreeNode parent, string path)
In this function you get yourself a list of all subdirectories of path (the Directory class has a method for this).
For each subdirectory you create a new TreeNode (with the subdirectory's name as node name) and add it to parent 's Nodes collection.
Then you call AddDirectoryNodes() from within itself with the newly added TreeNode as parent and the current subdirectory as path .
Voila, you get a nice tree structure of all directories.
Then all that remains is to enumerate all your drives, add a TreeNode for each drive and then call AddDirectoryNodes for these drive nodes.
Did this description help?
mav
|
|
|
|
|
Your pseudocode aided me in getting the final solution. THANK YOU!!
Here's the code for displaying all folders in your computer's logical drives in the windows explorer-style (assuming you have a hard drive C:\ and D:\:
string[] logical_drives = System.IO.Directory.GetLogicalDrives();
foreach(String drive_letter in logical_drives)
{
if(drive_letter.Equals("C:\\") || drive_letter.Equals("D:\\"))
{
TreeNode root_node = new TreeNode(drive_letter);
treeView1.Nodes.Add(root_node);
populateTreeView(drive_letter, root_node);
}
}
private void populateTreeView(string directory_name, TreeNode parent_node)
{
DirectoryInfo dir_info = new DirectoryInfo(directory_name);
DirectoryInfo[] directory_array = dir_info.GetDirectories();
foreach(DirectoryInfo current_directory in directory_array)
{
TreeNode new_node = new TreeNode(current_directory.Name);
parent_node.Nodes.Add(new_node);
if(current_directory.GetDirectories() != null)
populateTreeView(current_directory.FullName, new_node);
}
}
Now that I have the treeview filled with all the folders in my drives, I need to do 1 more thing. When I select a node, I write the full path of the node to a text file to save the path. When I reopen the application, I would like to have the same folder selected so I can resume my work in that folder. This is the code I would like to have, but it doesn't work:
StreamReader sr = new StreamReader("directory.txt");
if((line = sr.ReadLine()) != null && line != "")
{
treeView1.SelectedNode.FullPath = line;
sr.Close();
}
How can I select a given node at form load time?
|
|
|
|
|
Hi all,
I'm developing a custom DataGrid Column, that hosts a custom IPAddress Control.
I Should override the Paint mathod to paint the desiered text on the GridColumn
when the Paint method is called because the DataGrid USer clicks the last row in the grid to insert a new value.
i retrieve the value from the Column using "GetColumnValueAtRow ( source,rowNum )" and Paint it as shown in the code below.
i handled the problem of retrieving an invalid value but assign the NullText property that i previosly set.
But still the Paint draws 4 extra empty rows instead of only one.
anyway seems that i'm not handling the Paint method properly so does anyone knows how i should handle the Paint method when the User clicks on the last row in the DataGrid to insert a new value.
protected override void Paint
(
Graphics g,
Rectangle bounds,
CurrencyManager source,
int rowNum,
Brush backBrush,
Brush foreBrush,
bool alignToRight
)
{
try
{
string strIPAddress = "" ;
try
{
strIPAddress = ( string ) GetColumnValueAtRow ( source,
rowNum ) ;
}
catch
{
strIPAddress = this.NullText ;
}
Rectangle rect = bounds ;
g.FillRectangle ( backBrush,rect ) ;
rect.Offset ( 0, 2 ) ;
rect.Height -= 2 ;
g.DrawString ( strIPAddress ,
this.DataGridTableStyle.DataGrid.Font,
foreBrush,
rect ) ;
}
catch
{
System.Diagnostics.Debug.Assert ( false ) ;
}
}
|
|
|
|
|
when creating a windows service, I wanted to change the ServiceName property - in which IDE Properties window can I find the ServiceName property and change it to whatever name I want??
|
|
|
|
|
From the MSDN documentation.
The ServiceName identifies the service to the Service Control Manager. The value of this property must be identical to the name recorded for the service in the ServiceInstaller.ServiceName property of the corresponding installer class. In code, the ServiceName of the service is usually set in the main() function of the executable.
There isn't IDE support, you have to write code to set that value.
I can imagine the sinking feeling one would have after ordering my book,
only to find a laughably ridiculous theory with demented logic once the book arrives - Mark McCutcheon
|
|
|
|
|
Hello all,
I need to insert rows in access database table but the code give me "Sytax error in INSERT statement" but the insert works fine in access query
this the code:
<br />
OleDbConnection myConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source=L:\\Work\\Elkddeh\\Project\\Can\\Can_App\\bin\\Debug\\Can_DB.mdb;Mode=Share Deny None;Extended Properties=\"\";Jet OLEDB:System database=\"\";Jet OLEDB:Registry Path=\"\";Jet OLEDB:Engine Type=5;Jet OLEDB:Database Locking Mode=1;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False");<br />
string myInsertQuery = "INSERT INTO Can_Info (Can_ID,First_Name,Last_Name,Full_Name,Position,Last_Evaluation,Pass_Num,Issu_Date,Expire_Date,SB_Num,SB_Issu_Date,SB_Type,SB_Expire_Date,DOB,Email,Address,Phone1,Phone2,Mobile1,Mobile2,Last_Ship,Current_Ship,New_Crew,EX_Crew,Company,Medical_Report,Med_Date,Comment) VALUES ('1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28')";<br />
OleDbCommand myCommand = new OleDbCommand(myInsertQuery);<br />
myCommand.Connection = myConnection;<br />
myConnection.Open();<br />
myCommand.ExecuteNonQuery();<br />
myCommand.Connection.Close();<br />
please help
hay
|
|
|
|
|
|
hello all. could anybody tell me how i can package and deploy an application written in C#, and also about packaging the SQL database. ( like the Ms-Access that can ).
Best Regards to readers..
shahrouz
|
|
|
|
|
Create a deployment package. You can use either what's included with Visual Studio (check the Setup and Deployment Projects when you create a new project) or if you need added support check out products by InstallShield.com[^] or Wise[^]. Nullsoft also makes a nice installer package that is free, you can locate it here[^]
|
|
|
|
|
Dear sir... Appreciate your kindness....
|
|
|
|
|
Hi,
I have a word document in a stream, and I want to get the plain text out of it. How can this be accomplished without creating an instance of Word? I dont want to have to save my memory stream to disk, open it with a instance of word, save it as text and then load that text into a memory stream, as I need to parse MANY files as quickly as possible! (Search engine indexing)
I found an example in JAVA but it uses loads of java imports that I have no experience in, so I am unable to translate:
http://java2.5341.com/msg/49663.html[^]
Thanks for your time.
Tris
|
|
|
|
|
There are a few options.
- Get the index plugin for office documents that index server uses and use that in your application
- Open office
- a thrid party library like aspose.word, google around there are a few
I can imagine the sinking feeling one would have after ordering my book,
only to find a laughably ridiculous theory with demented logic once the book arrives - Mark McCutcheon
|
|
|
|
|
Is there a way to do this? There are no color properties for these controls. I guess I have to override some Windows messages to do so. Can someone point me in the right direction?
|
|
|
|
|
You create create a custom ScrollBar to handle this. Here[^] is an example, though it is done in VB.NET, it shouldn't require much to convert it over to C#.
|
|
|
|
|
If i use ListViewItem.BeginEdit How to determine where the Item is click
|
|
|
|
|
Hi,
I have a VC++ DLL exports a function with an input argument is object of CString.
When I use DllImporter to call this function in C#, but it's not successful (.NET framework says that it cannot find the entry point)
Pls help me
Thanks in advance
|
|
|
|
|
Hi fellow CPians!
I'm having a hard time trying to create the C# declarations for several SAPI (MS Speech API) 4.0a interfaces, perhaps somebody can give me a litte tip...
Several interfaces deal with an obscure struct SRPHRASE, defined like this:
typedef struct {
DWORD dwSize;
BYTE abWords[0];
} SRPHRASEW, * PSRPHRASEW; Although abWords is declared as a BYTE array, the documentation states that abWords is "Memory containing a list of SRWORD structures, in temporal order".
SRWORD is defined like this:
typedef struct {
DWORD dwSize;
DWORD dwWordNum;
WCHAR szWord[ ];
} SRWORD, *PSRWORD; The idea behind this is to call the interface function ISRResBasic::PhraseGet
HRESULT PhraseGet(
DWORD dwRank,
PSRPHRASE pSRPhrase,
DWORD dwPhraseSize,
DWORD *pdwPhraseNeeded) where pSRPhrase's documentation reads: "[out] Address of an SRPHRASE structure to receive the phrase." and for dwPhraseSize: "[in] Number of bytes available in the structure specified by pSRPhrase. If the number is too small, PhraseGet returns SRERR_NOTENOUGHDATA and fills in pdwPhraseNeeded with the number of bytes needed."
So far I've tried declaring PhraseGet as:
void PhraseGet(UInt32 dwRank, ref SRPHRASEW pPsrPhrase, UInt32 dwPhraseSize, out UInt32 pdwPhraseNeeded); but no matter how I declare SRPHRASE, I always get a COM exception (HRESULT 0x800706C6)
I don't know how to declare these structs in a way that they can be marshalled correctly.
Any hints would be appreciated!
Thanks in advance,
mav
|
|
|
|
|
How to use progress bar show the real processing of CPU.
|
|
|
|
|
You going to have to be ALOT more specific about what you want to do. What do you mean by "real processing of CPU"?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hello there,
I am an ameteur programmer in C# and i am currently doing a project related with WLAN design. I intend to take CAD files as input, more precisely, I want to take architectural floor plan as input, process them, i.e. Assign each wall and obstacle a separate factor of say attennuation of RF signal. Based on the structure I create like i told above i want to map the coverage of the wireless device like access point antenna, so i intend to use clipping as well.
I am having no clue as to how do i set these properties of obstacles in CAD file which is .dwg format and then how do i proceed further..i have a few ideas, which are not concrete. and in the first step i am looking for an SDK which can help me to do programming with CAD files.
Please reply ASAP I am in deep trouble...
Thanks
Abhinandan S. Shah
|
|
|
|
|
An "ameteur programmer" with a very ambitious project like this? You're right, you are in deep trouble!
Abhinandan_Shah wrote:
in the first step i am looking for an SDK which can help me to do programming with CAD files.
Have you tried Googling for a library first? Google Search Results[^]
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hey,
Thanks dave. Actually speaking, I am not exactly an ameteur programmer however I am a an ameture CAD programmer, And as only some part of my project involves CAD programming, I think what I am thinking about is possible, as a matter of fact I have come across 2 Options one is using the ObjectDBX technology from autodesk, and the other is using OPenDWG toolkit from OpenDesign Alliance.
As I am doing my project in C#, I would really want someone to help me in using the ObjectDBX library. Because I have finalized on using it. And after loot of googling, and clustying and many more days of hectic searching i have found this solution which i would like to share, otherwise, Cadsofttools.com has also been an useful resource, but they wouldnt respond to my email.
Thanks for showing concern, I would really appreciate if you help me become a professional from an ameture!!and I feel this is the platform to share your programming dreams isnt it?
Regards
Abhinandan Sunil Shah
|
|
|
|
|
I haven't done any CAD work like this at all, and frankly, your going to find a very small community of people here that has. Your best bet would be to find a forum that is specifically for the library your using. At least there, you'll find an experience base that has used the product your using.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi
this is exact problem.
when i add webmethod to webservice and build it and update
client webreference, client knows the new webmethod without any problem.
but when i add a new class to webservice project and build it and update client webreference, client doesnt know the new class.
Note:this is a new problem and a few days ago when i added
a new class to webservice client could knows new class.
this problem is for new solutions too.
|
|
|
|
|
Hi
For understanding my problem, I will explain what my program does.I will give instructions, what to do , u can see that. And I will say what my requirement is ,, so that u can rectify my problem.
I have a 3 textboxes in the form.
Theer is a xml file with a value named "style_desc" in it.(ie, Field Names.xml in the project directory)
1st Textbox ------ give the schema file.(Input Schema.xsd from the project directory)
2nd TextBox------- give the input xml file( styleData.xml in the project directory)
some about 30 values for a single field named "style_desc."
3rd TextBox-------- give ur own path to create an xml file with data's fo rthe xml schema.
Then click button LOAD----- what it does is that stores the value(from the Feld Nams.xml) in an array and checks for the entered schema(ie, Input Schema.xsd) that there is ay field named "style_desc". Then if it exists in the schema then itreads the values of "style_desc" and stores into a new xml(for the third Textbox file) and the reamining fields of schema will be automatically loaded with values accodring to the datatype for about 200 values.
ie, for string ---- castle hampers1, castle hampers2.... upto 200 names
for float ----- 4.5, 5.5,.... upto 200 values
so for the style_desc column alone(for 200 data's), first 30 values from the styleData.xml (as ther is only 30 values)and the remaining will be castle hampers31, 32.... so on.
this is what I did.
Now my requirement is that I have some other xml file (say billtodata.xml ) with about 30 values for a field named "billto_name"..
Now I should add "billto_name" along with "style_desc" in the xml file(Field Names.xml) . Now it should be also stored in the array and check for the schema whether there is any existence of the field named "billto_name" trhen if it exists it should read the values from billtodata.xml and load it into the new xml with the values for the billto_name.
so Like this I will be adding mor xml file with values for single field . So can u please finish it for me . or else give the correct idea with some coding help.
I think u will be clear now ..
This is very urgent need for me.Here is my coding part. please correct me to do my requrement.
here is my coding part where under the load button I have this.there will some *****************. that is the place wher I will load styledata.xml.
private void button2_Click(object sender, System.EventArgs e)
{
ArrayList FiledNames = new ArrayList();
XmlDocument xdc = new XmlDocument();
//Read the file which contain the field names
xdc.Load(@"C:\CDEV\testdatagenerator\Field Names.xml");
XmlNodeList nodFields = xdc.DocumentElement.SelectNodes("//item");
for(int i=0; i
|
|
|
|
|