|
I am having a problem with the Directory package. I need to create a list of a root directory and all of the sub-directories associated with that root. I am currently using the System.IO.Directory.GetDirectories(_PathName) to get a list of the first level of subdirectories. This returnes a string array of the subdirectories. Now i need to go anothers step down and check all of these subdirectories for additional subdirectories. The problem is that i could do this but i am not quite sure how to extend this for an unknown amount of levels within the directroy structure. Any help would be appreciated.
Thanks
|
|
|
|
|
 Hi
this is a code i use to copy a directory tree..
and I readthe directory tree..(The same as your program)
read it and get the idea
private void cmdCopy_Click(object sender, System.EventArgs e)<br />
{<br />
if(!Directory.Exists(txtDist.Text))<br />
{<br />
MessageBox.Show("Please enter a valid path");<br />
return;<br />
}<br />
DirectoryInfo dir=new DirectoryInfo(txtSrc.Text);<br />
CopyDirectory(txtSrc.Text,txtDist.Text+"\\"+dir.Name);<br />
MessageBox.Show("OK");<br />
}<br />
<br />
private void CopyDirectory(string src,string dist)<br />
{<br />
if(!Directory.Exists(dist))<br />
Directory.CreateDirectory(dist);<br />
<br />
FileInfo file;<br />
DirectoryInfo dir;<br />
string[] strFiles;<br />
string[] strDirs;<br />
<br />
strFiles=Directory.GetFiles(src);<br />
foreach (string strFile in strFiles)<br />
{<br />
file=new FileInfo(strFile);<br />
file.CopyTo(dist+"\\"+file.Name);<br />
}<br />
<br />
strDirs=Directory.GetDirectories(src);<br />
foreach (string strDir in strDirs)<br />
{<br />
dir=new DirectoryInfo(strDir);<br />
if(dir.FullName==dist)
continue;<br />
CopyDirectory(dir.FullName,dist+"\\"+dir.Name);<br />
}<br />
}
|
|
|
|
|
Does anybody know of a way when developing your own VS.NET add-in, to access all the server connections? What I want to do is grab all the tables from the databases listed in their and place them on a treeview in my addin.
I know its not the best place to post this, but there is no "CRAZY QUESTION YOU WOULD ASK WHEN WRITING AN ADD IN FOR VS.NET" forum is there guys? (blush)
Ta!
Nursey
|
|
|
|
|
Hi,
I made 2 custom controls, both of which have a default constructor. The problem is that when I try to drag one of them into the form from the toolbox, I get a message saying that an exception occured while trying to create an instance of the control. The exception text is "Object reference was not set to an instance of an object."
Now with the other control, it works Ok when I drag it onto the form and works as expected when I run the program, however if I try to delete it from the form I also get an "Object reference was not set to an instance of an object." exception.
Can you please help me locate the source of this error?
Thanks for your help.
Josef
|
|
|
|
|
Problems found and fixed.
Thanks,
Josef
|
|
|
|
|
hi, am trying to load values from config file in windows service project installer but it fails to load, then i tried to load that config file using xmldom, it worked but in this way installer looks for the file in system32 directory rather than in my installation directory.
How can i do that 
|
|
|
|
|
The application's .config file is read from the same directory as the application executing your installer - not the installer itself. So, if you use the installutil.exe, then installutil.exe.config is used from the same directory where installutil.exe is executed (not the current working directory).
You should typically not use .config files with installers for this reason - your installer class is typically contained in a DLL and executed by something else. Instead, accept command-line parameters which make it more flexible, easy to document (see the Installer.HelpText virtual property), and easy to use even with Windows Installer packages (which you can pass properties as command-line parameters.
See the Installer.Context property documentation in the .NET Framework SDK for more information and an example of how to get those properties from the installer's context.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
hi
i`m new user in code project
my name is hmd
i want your help ..
1 - who can sending data bitween client , server by using
xml form.
I `m wating ......
thank you
|
|
|
|
|
hmdhmd wrote:
who can sending data bitween client , server by using
xml form.
Anyone, however if you have a specific question, try asking that.
- Nick Parker My Blog | My Articles
|
|
|
|
|
I cant find this error in the msdn help file. Wanted to know if anyone had a clue on what it was. Arxopia-En is a DLL that compiles and has a few string resources in it. This is just a snip of the code but it is the only part of the code that uses the RM atm. Do i need to provide more info, just cant seem to figure out the meaning of this error.
Assembly generation -- Referenced assembly 'Arxopia-EN' is a localized satellite assembly
<br />
namespace HammackJ.Arxopia.Engine<br />
{<br />
using System;<br />
using System.Resources;<br />
using System.Reflection;<br />
using System.Text;<br />
using Arxopia;<br />
using Arxopia.Resources;
<br />
public class Menu<br />
{<br />
ResourceManager rm;<br />
<br />
public Menu()<br />
{<br />
rm = new ResourceManager("Arxopia.Resources.Arxopia_En.GameStrings", Assembly.GetAssembly(typeof(Arxopia.Resources.Arxopia_En)));<br />
<br />
}<br />
}<br />
<br />
|
|
|
|
|
You can't explicitly reference satellite assemblies - Fusion does this automatically.
The satellite assemblies contain localized values (text or binary data encoded as text, typically using base64) for information in your primary assembly. So, if you create a new ResourceManager against, say, a Form derivative then a .resources embedded resource is used (if available) to find those localized resources. If the current Thread.CurrentUICulture</code. is different or you pass a specific <code>CultureInfo to something like ResourceManager.GetString or ResourceManager.GetObject , then a corresponding satellite assembly is searched for and loaded if available, otherwise the resources in your primary assembly - the neutral language resources - are used (or a culture-independent language, if available). This lookup can be avoided for neutral resources if you use the NeutralResourcesLanguageAttribute and set that to your culture-specific language which you use for the primary assembly (like I would use "en-US"). This can boost performance when using localized resource classes like the ResourceManager .
See Resources in Applications[^] in the .NET Framework SDK for more information.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks a ton again sir. I had En in the [assembly: AssemblyCulture("")] tag in the assemblyinfo.cs. Now it complies correctly.
Again thank you for your help.
-hammackj
|
|
|
|
|
You also shouldn't name your assembly with "EN" in the name, if you did that. Make sure you read that link I gave you. Your assembly name should be something simple, like MyCompany.MyProduct or something, and includes the neutral resources. If that's "en-US", then no satallite assemblies would need to be loaded but you still don't name your primary assembly with culture identification - it's just not proper and your satallite assemblies become oddly named an confusing.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
how to make a chat program one server multi client by c#
note that :
each client can talk with the server only.
all clients can send and receive to/from server .
sameer
|
|
|
|
|
This can be very simply done using web services.
You can create web service with method for sending messages and method for geting content of chat window.
You can store messages on server in database or simply in memory or xml file.
Also creating client that uses web services is simple.
You can see tutorial about using web services here http://samples.gotdotnet.com/quickstart/aspplus/doc/webservicesintro.aspx[^].
|
|
|
|
|
.NET Remoting over a TcpChannel would be even better, however. Using XML Web Services forces the chat clients to poll for new messages, while a .NET Remoting object that exposed events could notify - it not send - the new messages to the clients immediately.
Since Web Services uses HTTP for the transport channel, they are bound by the HTTP protocol which is stateless and one-way by nature.
See the article, Applying Observer Pattern in .NET Remoting[^] for a decent example.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
You are right.
Using web services for more complex chat application isn't good way, but I think that solution with web services is good enough for simple chating application (if there are only few users). And I tought that azhar ( I'm not sure with name) wants something more simple.
|
|
|
|
|
Web Services really don't make things any simpler, though. Remember that if you poll for messages, the server has to keep track of messages since the last time the client polled, and the clients - even a relatively small number of them - won't poll at the same time so the message queue would have to be associated with each client or you'd have to implement some algorithm where you keep track of the number of clients connected and clear the queue after that many requests for messages. With that, you have to worry about abnormal client termination to decrement that count.
With .NET Remoting, the message just gets broadcast to the connected clients and that's it. .NET Remoting isn't nearly as hard as many think it is.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hello everyone...this is my first question on this forum, I'm using Internet Explorer 6 for syntactically checking XML documents (mainly to detect unclosed tags) in my application.
How can I capture the output of Internet Explorer after it parses the file so I can display it on my application?
Is it a must to use a COM object for applications interaction?
Thanx in advance for all ppl contributing to this beautiful website .
|
|
|
|
|
Why don't you just read it into an XmlDocument or an XmlTextReader , which will verify that it's well-formed. Using Internet Explorer - which actually uses MSXML - is totally unnecessary and very inefficient. Once you've got it into an XmlDocument , you can perform XSL transformation, XPath queries, or just navigate and modify the DOM. If you use an XmlTextReader , you could just read it in as text.
If you want to validate it against a schema - something Internet Explorer/MSXML doesn't do automatically - you can use an XmlValidatingReader .
Just see the documentation for these classes in the .NET Framework SDK for more information and examples.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanx Heath, the thing is that I want to know how get an output of any program that you launch within the code. say that IE returned an error, can I detect that and show it to the user?
Using those classes is my next task, first I have to use IE for syntax checking..it is a must.
|
|
|
|
|
forgiven4u wrote:
first I have to use IE for syntax checking
That's what I'm getting at - the XML classes in the .NET Framework check for well-formedness and perform schema validation if you want. This will return you were the error is and let you fix it. You're really taking a backward approach to doing something so simple. Remember, IE isn't even the one validating your XML well-formedness (it doesn't do schema validation) - it's MSXML which IE uses.
forgiven4u wrote:
the thing is that I want to know how get an output of any program that you launch within the code.
There is no universal way of doing this. Sometimes you can redirect stdout and stderr, sometimes you can use the Windows APIs to get Window text, and sometimes you must read a DOM. Every application is designed differently.
forgiven4u wrote:
say that IE returned an error, can I detect that and show it to the user?
If you used the XML classes in .NET, you wouldn't have to worry about this because any invalid XML will throw an exception while loading, giving you the information to present to the user so they can fix it. Besides, if IE is visible, it will display the error.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks again Heath, redirecting stdout & stderr is one cool technique I was seeking. I want to execute a program (no IE) and get it's output.
Such attentive people like you makes the world a better place.
|
|
|
|
|
Do you know the answer how to add/remove references for specific configuration?
I have 2 configurations in my project, "Debug" and "Release" (as usual). I also use a NUnit and other tools that help to develop stable applications. In order to use NUnit I have to add reference: "nunit.farmework" to the list of all project references.
My problem that I don't want to add the reference in the "Release" configuration, I don't want to install NUnit or even copy nunit.framework.dll to the client machine.
Do you know a way to "dynamically add/remove reference for a specific configuration?"
Could reflection help?
Thanks in advance
|
|
|
|
|
I don't think this is possible, and a solution I found is to create a separate DLL where I put all the unit tests. This way I ensure that I only ship release code to our customers, and that I can freely add "tool references" such as NUnit, mock libraries, etc.
IMO, Reflection would not help you because there's no way to add attributes ([Test], [ExpectedException], etc) to a class after it has been loaded.
Due to technical difficulties my previous signature, "I see dumb people" will be off until further notice. Too many people were thinking I was talking about them...
|
|
|
|