|
Hello
Yes !
you can use WMI to get all connected drives
|
|
|
|
|
Of course you can ... alot of ways to do so and WMI is one of them ... use the System.Management namespace to help you so ... as follows:
ArrayList list = new ArrayList();
using (ManagementObjectSearcher DiskSearch = new ManagementObjectSearcher(new SelectQuery("Select * from Win32_LogicalDisk")))
{
using (ManagementObjectCollection moDiskCollection = DiskSearch.Get())
{
foreach (ManagementObject mo in moDiskCollection)
{
list.Add(mo["Name"].ToString ());
MessageBox.Show(mo["Name"].ToString());
mo.Dispose();
}
}
}
Dont forget to add a reference in your project to System.Management dll and you will get all the drives .. for more properties go to this link to get them (other than the Name property used here):
http://msdn.microsoft.com/en-us/library/aa394173.aspx[^]
Enjoy !
Note: If you found this answer useful please indicate that so other would know so.
Sincerely Samer Abu Rabie
Software Engineer
|
|
|
|
|
All,
thanks to led mike I have a new project template in my 'create project' part of VS2005. Opening it opens my wizard dialog and after some options I can start creating my custom solution.
My code however crashes on the AddFromTemplate method.
(EnvDTE.Project proj = MySolution.AddFromTemplate( ... ); )
it gives a HRESULT failed from the com interop error. I check my path and the example of MSDN and it looks OK.
My guess is that the project template I use is not really valid (exact copy of the standard windowsapplication project)
Can anyone help me with this?
MSDN[^] doesn't seem to explain what exactly you need to do...
thanks a lot (nearly there , maybe I can write an article about it in exchenge if I get it to work )
|
|
|
|
|
I have a string and I want to compare to another string, and if they are not equal I want my app to do something. How is the not equal statement in C#? Like for equal we have: if(string.Equals(anotherString)) do something. How should I declare if is not equal? Thx
|
|
|
|
|
|
|
I recommend if you really want to learn C#, you buy a book. You really need to have a reference for basic questions like this and not to have to rely on web forums.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
Christian Graus wrote: I recommend if you really want to learn C#, you buy a book. You really need to have a reference for basic questions like this and not to have to rely on web forums.
Why?? All the VB developers here (my office), have a terrible fear of Google and any form of documentation.
|
|
|
|
|
huh ?
|
|
|
|
|
leppie wrote: All the VB developers here (my office), have a terrible fear of Google and any form of documentation
I thought you'd have managed to hunt them all down and brand them by now.
|
|
|
|
|
Yes, but this is the C# forum.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
Strictly speaking, string comparisons should be done using the special internationalized comparison operations such as string.Compare();[^].
|
|
|
|
|
Pete O'Hanlon wrote: Strictly speaking, string comparisons should be done using the special internationalized comparison operations such as string.Compare();[^].
Very strictly speaking you want to use CompareInfo.Compare for locale independent strings, eg case-insensitive compare of "strasse" and "Straße".
|
|
|
|
|
...guys, I didn't knew that such a simple question would gain such an attention
|
|
|
|
|
leppie wrote: Very strictly speaking you want to use CompareInfo.Compare for locale independent strings, eg case-insensitive compare of "strasse" and "Straße".
Well, I did link to String.Compare(String, String, CultureInfo, CompareOptions) .
|
|
|
|
|
Pete O'Hanlon wrote: Well, I did link to String.Compare(String, String, CultureInfo, CompareOptions).
That is not in my .NET! Which one are you using?
|
|
|
|
|
This member was introduced in .NET Framework 2.0 SP2, 3.0 SP2 and 3.5 SP1.
|
|
|
|
|
Pete O'Hanlon wrote: This member was introduced in .NET Framework 2.0 SP2, 3.0 SP2 and 3.5 SP1.
I do not have 3.5 SP1 (I assume this installs the other SP's too). And your original link does not work... Both IE and FF reports an error.
|
|
|
|
|
Refresh the page after the error. I just had this issue, and it refreshes it OK.
|
|
|
|
|
Urggg. Seems MSDN is down for me, tried some other links now, same result...
|
|
|
|
|
Finally got it loaded, interesting. Thankfully they have a big warning to show that you should not normally have to use this for equality comparison.
|
|
|
|
|
Hi all
I am trying to save my settings into app.config but it doesn't work. I can read data but I can't save it. I see no error.
Can you give me a hint. Here is my code.
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
config.AppSettings.Settings.Remove("ClientPort");
config.AppSettings.Settings.Add("test", "23232");
config.Save(ConfigurationSaveMode.Full, true);
ConfigurationManager.RefreshSection("appSettings");
Thanks.
|
|
|
|
|
daavena wrote: ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
User based .config files live in another location, somewhere in Documents and Settings/Username/blah/blah.
You probably want to use: PerUserRoamingAndLocal
|
|
|
|
|
I used directx capture dll ,now i want to compress any format ,how to diffreent from one to another audio codecs ,
for example some audio codecs listed in listbox .i want which one is selected the file is created that format ie) if selected mp3 compresser file name is like www.mp3 if selected wma compresser file name is like www.wma
regards
anish...
|
|
|
|
|
I'm sorry, I can't work out what you're asking. You want to have a listbox of codecs and work out what filenames to give them ?
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|