|
How do I get disk volume info in C#? (without having to traverse thru all dirs)
the same info as this function in C++:
GetDiskFreeSpaceEx(str, &lpFreeBytesAvailableToCaller,
&lpTotalNumberOfBytes, &lpTotalNumberOfFreeBytes );
Thanks.
mnnca
mnnca
|
|
|
|
|
You can use DllImport attribute to call GetDiskFreeSpaceEx from your C# code. This is for you to explore: P/Invoke[^]
By the way, DriveInfo Class[^] has quite many information about drives.
Giorgi Dalakishvili
#region signature
my articles
#endregion
modified on Thursday, May 15, 2008 5:43 PM
|
|
|
|
|
Thanks for the help.
I can't get the DllImport to work.
I don't know if it's because of my old IDE (2003).
I've installed up to .net frw 3.5.
System.IO still doesn't have the function "DriveInfo".
When I tried this:
[DllImport("user32.dll")]
public static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
the error is:
at "bool"
Expected class, delegate, enum, interface, or struct
why?
Thanks again.
mnnca
mnnca
|
|
|
|
|
DriveInfo class appeared in .Net Framework 2.0 so you need Visual Studio 2005 or later. As for GetDiskFreeSpaceEx pinvoke.net[^] can help you.
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
Thanks again.
I did try several DllImport code samples from PInvove. They all have the same syntax error.
I think it's my old IDE problem, it cannot open/run most of samples.
I'll need to buy the new .net version (if my boss can get budget for the whole sw group. doubt it!).
regards,
mnnca
mnnca
|
|
|
|
|
You can download Express version of VS2008 and try it there.
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
I dont have msdn subscription.
we're still using 6.0 (due to limitation of hardware device drivers, and users' hardware). We bought .net 2003 to learn it only.
mnnca
|
|
|
|
|
Well, theres the System.IO.DriveInfo class which gives a little information on a drive:
DriveInfo di = new DriveInfo(@"C:\");
Console.WriteLine(" Free Space: {0}MB", (di.AvailableFreeSpace/1048576));
Console.WriteLine(" Used Space: {0}MB",(di.TotalSize-di.AvailableFreeSpace)/1048576);
Console.WriteLine("Total Space: {0}MB",di.TotalSize/1048576);
1048576 is 1024*1024 because the properties return the number of bytes.
There's also FileInfo and DirectoryInfo classes, incase you ever want to use those too.
My current favourite word is: Bacon!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
Hi,
I concur.
Except, if you mean 1024*1024, then why don't you write it like that, preserving optimal
readability? the compiler will do what is necessary and generate exactly the same code...
|
|
|
|
|
Yeah yeah, think your so clever don't you
Thats just how i wrote it, then i thought i better mention where i pulled the number from. I guess it comes down to "I was to lazy to change the code"
My current favourite word is: Bacon!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
SK Genius wrote: I was to lazy to...
The point is you don't need to first complicate the code and then add comments
to make a reader understand it; instead just keep it simple from the start!
|
|
|
|
|
SK Genius wrote: Yeah yeah, think your so clever don't
No, he knows so
I doubt it. If it isn't intuitive then we need to fix it. - Chris Maunder
|
|
|
|
|
Thanks for your help.
I can't get the "DriveInfo" to work.
Please see my reply to Giorgi Dalakishvili.
regards,
mnnca
mnnca
|
|
|
|
|
I am having a form with a textbox and a button..the text box has the value of Zoom In percent..Say for instance 40..When the button is clicked...an image is to be zoomed(for 40%)..How cani do this? Any Clues? or if you have savings of code pl do send..wud b lot helpful.Thanks
|
|
|
|
|
Arun80403 wrote: Any Clues?
Use Search.
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
cudnt find any...
Don't try to make someone love you..Try to be the one who can be loved...
|
|
|
|
|
|
you zoom an image by drawing it bigger - look at the DrawImage overloads on the Graphics class that let you specify the area to draw AND the area to draw it to.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
So yeah, like Chris said, use the DrawImage overloads.
To zoom 40% you need to multiply the width of the image by 0.4, so something like DrawImage???(myImage, myImage.Width*0.4...);
I'm not sure on what the overloads actually are, or what parameters they take.
You will of course be needing to draw the image yourself, rather than using a pictureBox.
My current favourite word is: Bacon!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
I am trying to get these 2 programs to work together.. one prevents autoplay in windows xp and the other detects the drive letters for newly inserted media.. The problem is, autoplay is in VB and the drive detector is in C#..
Currently, I only know a little C# and no VB.. and using online converters has not helped any, as there is always an error of some sort.. The main thing I'm trying to do, is convert one language to the other, and put them together into one program, with the end result of a program that stops autoplay while detecting new drives..
If somebody finds this file on this site.. tell me and i will change it..This is the program to prevent autoplay..
PreventAutoplay(VB)[^]
and this one detects the drive letters..
DriveDetector(C#)[^]
|
|
|
|
|
To convert VB.net to C# download sharp develop.
If it's VB6 you're SOL and will have to do a manual port.
You know, every time I tried to win a bar-bet about being able to count to 1000 using my fingers I always got punched out when I reached 4....
-- El Corazon
|
|
|
|
|
Great program...works just as good as the website ive been using..but it has an issue after converting...a few errors that i am unable to fix..would somebody who knows what they are doing please help out a bit?..convert real quick and help me fix any errors it has?
|
|
|
|
|
No conversion program is perfect. IF you posted the code in question, perhaps we could help.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Is there a way to view the contents of a merge module through VS.NET or through some other free viewing tool?
|
|
|
|
|