Click here to Skip to main content
15,905,325 members
Home / Discussions / C#
   

C#

 
QuestionIs 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 afte Pin
Xarzu6-Oct-11 1:11
Xarzu6-Oct-11 1:11 
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
Not Active6-Oct-11 2:28
mentorNot Active6-Oct-11 2:28 
GeneralRe: 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
TheGreatAndPowerfulOz6-Oct-11 7:23
TheGreatAndPowerfulOz6-Oct-11 7:23 
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 
Greetings Gurus,

While enumerating the drives in my machine I am trying to get the output to print "No Label" if the VolumeLabel value is null / length = 0.

When I run the app, after the C: and D: respond, I keep getting an exception "the device is not ready" if I use the "No Label" qualifier, but the code runs fine with that bit commented out.

What syntax should I be using please?

C#
DriveInfo[] allDrives = DriveInfo.GetDrives();

        foreach (DriveInfo d in allDrives)
        {
            if (d.VolumeLabel.Length == 0)//Exception occurs here
                d.VolumeLabel = "No Label";
            string label = d.VolumeLabel;
            if (d.IsReady == true)
            {
                Console.WriteLine(d.Name);
                Console.WriteLine(d.DriveType);
                Console.WriteLine(d.VolumeLabel);
                Console.WriteLine(d.DriveFormat);
                Console.WriteLine(d.AvailableFreeSpace / 1024000000);
                Console.WriteLine(d.TotalFreeSpace / 1024000000);
                Console.WriteLine(d.TotalSize / 1024000000);
            }
        }

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 
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 

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.