Click here to Skip to main content
15,903,388 members
Home / Discussions / C#
   

C#

 
AnswerRe: Is there a way to find out if a query will return data before it is made? I have an unusual problem. My code uses a 3rd party dll to make database calls from my silverlight client to a sql server database. In my code, I make dozens of calls one Pin
Eddy Vluggen6-Oct-11 6:46
professionalEddy Vluggen6-Oct-11 6:46 
QuestionDisplaying an image generated in c++/CLI DLL Pin
eyalbi0076-Oct-11 0:38
eyalbi0076-Oct-11 0:38 
AnswerRe: Displaying an image generated in c++/CLI DLL Pin
BobJanova6-Oct-11 1:05
BobJanova6-Oct-11 1:05 
AnswerRe: Displaying an image generated in c++/CLI DLL Pin
Luc Pattyn6-Oct-11 2:46
sitebuilderLuc Pattyn6-Oct-11 2:46 
QuestionHelp with DriveInfo. VolumeLabel exception please Pin
CCodeNewbie5-Oct-11 22:55
CCodeNewbie5-Oct-11 22:55 
AnswerRe: Help with DriveInfo. VolumeLabel exception please Pin
CCodeNewbie5-Oct-11 23:08
CCodeNewbie5-Oct-11 23:08 
GeneralRe: Help with DriveInfo. VolumeLabel exception please Pin
Pete O'Hanlon5-Oct-11 23:26
mvePete O'Hanlon5-Oct-11 23:26 
AnswerRe: Help with DriveInfo. VolumeLabel exception please Pin
Manfred Rudolf Bihy5-Oct-11 23:17
professionalManfred Rudolf Bihy5-Oct-11 23:17 
Of course you're getting that exception if you ask the volume label of a drive that doesn't have any media inserted like a DVD, CD, BlueRay drive for instance:

C#
DriveInfo[] allDrives = DriveInfo.GetDrives();
long divisorForGiga = 1024 * 1024 * 1024;
foreach (DriveInfo d in allDrives)
{
    String label = d.VolumeLabel;
    if (d.IsReady == true)
    {
        if (d.VolumeLabel == null || d.VolumeLabel.Length == 0)
        {
            // I'm not sure if you can assign to VolumeLabel in any case
            // You'll have to check and see if it works
            d.VolumeLabel = "No Label";
        }
        Console.WriteLine(d.Name);
        Console.WriteLine(d.DriveType);
        Console.WriteLine(d.VolumeLabel);
        Console.WriteLine(d.DriveFormat);
        Console.WriteLine(d.AvailableFreeSpace / divisorForGiga);
        Console.WriteLine(d.TotalFreeSpace / divisorForGiga);
        Console.WriteLine(d.TotalSize / divisorForGiga);
    }
    else
    {
         Console.WriteLine("Drive {0}: is not ready! Maybe there's no media inserted.")
    }
}


Cheers!

—MRB

"With sufficient thrust, pigs fly just fine."
Ross Callon, The Twelve Networking Truths, RFC1925

GeneralRe: Help with DriveInfo. VolumeLabel exception please Pin
Matt Meyer6-Oct-11 11:20
Matt Meyer6-Oct-11 11:20 
GeneralRe: Help with DriveInfo. VolumeLabel exception please Pin
Pete O'Hanlon6-Oct-11 12:01
mvePete O'Hanlon6-Oct-11 12:01 
Questionc# binary to decimal code -new- Pin
mehmetali_065-Oct-11 19:41
mehmetali_065-Oct-11 19:41 
AnswerRe: c# binary to decimal code -new- PinPopular
Peter_in_27805-Oct-11 20:18
professionalPeter_in_27805-Oct-11 20:18 
GeneralRe: c# binary to decimal code -new- Pin
mehmetali_066-Oct-11 20:47
mehmetali_066-Oct-11 20:47 
GeneralRe: c# binary to decimal code -new- Pin
Perić Željko7-Oct-11 7:47
professionalPerić Željko7-Oct-11 7:47 
GeneralRe: c# binary to decimal code -new- Pin
Peter_in_27807-Oct-11 11:49
professionalPeter_in_27807-Oct-11 11:49 
GeneralRe: c# binary to decimal code -new- Pin
KP Lee10-Oct-11 10:57
KP Lee10-Oct-11 10:57 
GeneralRe: c# binary to decimal code -new- Pin
Peter_in_278010-Oct-11 14:42
professionalPeter_in_278010-Oct-11 14:42 
GeneralRe: c# binary to decimal code -new- Pin
KP Lee10-Oct-11 15:05
KP Lee10-Oct-11 15:05 
NewsRe: c# binary to decimal code -new- Pin
Perić Željko7-Oct-11 7:56
professionalPerić Željko7-Oct-11 7:56 
AnswerRe: c# binary to decimal code -new- Pin
KP Lee10-Oct-11 14:51
KP Lee10-Oct-11 14:51 
GeneralRe: c# binary to decimal code -new- Pin
Peter_in_278011-Oct-11 12:41
professionalPeter_in_278011-Oct-11 12:41 
GeneralRe: c# binary to decimal code -new- Pin
KP Lee11-Oct-11 13:55
KP Lee11-Oct-11 13:55 
QuestionGood reporting and database tools for C# ? Pin
Stan Moong5-Oct-11 18:22
Stan Moong5-Oct-11 18:22 
AnswerRe: Good reporting and database tools for C# ? Pin
Eddy Vluggen6-Oct-11 6:55
professionalEddy Vluggen6-Oct-11 6:55 
GeneralRe: Good reporting and database tools for C# ? Pin
Stan Moong6-Oct-11 14:31
Stan Moong6-Oct-11 14:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.