PC Review


Reply
Thread Tools Rate Thread

DriveInfo.GetDrives method problem.

 
 
Emil
Guest
Posts: n/a
 
      24th Dec 2006
Hi,
I've written an application similiar to Total Commander but there is one
problem. To obtain all available drive letters I use DriveInfo.GetDrives()
method but it works only on my computer. If I try running this application
on other computers I get an IOException. What should I do ?

PS. Merry Christmas to everyone.



 
Reply With Quote
 
 
 
 
Duggi
Guest
Posts: n/a
 
      24th Dec 2006
Place Try..catch block for the statement DriveInfo.GetDrives() and
catch the IO Exception Properly. Exception.Message would give you the
reason why it is failed. Sample code here

try
{
DriveInfo[] driveInfo = DriveInfo.GetDrives();

foreach (DriveInfo di in driveInfo)
{
Console.WriteLine(di.Name);
}
}
catch (IOException exp)
{
MessageBox.Show(exp.Message);
}

Compile the code in "AnyCPU" mode

Thanks
-Srinivas.

Emil wrote:
> Hi,
> I've written an application similiar to Total Commander but there is one
> problem. To obtain all available drive letters I use DriveInfo.GetDrives()
> method but it works only on my computer. If I try running this application
> on other computers I get an IOException. What should I do ?
>
> PS. Merry Christmas to everyone.


 
Reply With Quote
 
Emil
Guest
Posts: n/a
 
      25th Dec 2006

Uzytkownik "Duggi" <(E-Mail Removed)> napisal w wiadomosci
news:(E-Mail Removed)...
> Place Try..catch block for the statement DriveInfo.GetDrives() and
> catch the IO Exception Properly. Exception.Message would give you the
> reason why it is failed.


I did as you wrote and the message is: "Request for the permission of type
'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.".

It's sounds silly to me. All I wanted is just to read the disk label but the
CLR behaves like it was a virus at least. And still don't know what to do


 
Reply With Quote
 
cody
Guest
Posts: n/a
 
      3rd Jan 2007
Emil wrote:
> Uzytkownik "Duggi" <(E-Mail Removed)> napisal w wiadomosci
> news:(E-Mail Removed)...
>> Place Try..catch block for the statement DriveInfo.GetDrives() and
>> catch the IO Exception Properly. Exception.Message would give you the
>> reason why it is failed.

>
> I did as you wrote and the message is: "Request for the permission of type
> 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0,
> Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.".
>
> It's sounds silly to me. All I wanted is just to read the disk label but the
> CLR behaves like it was a virus at least. And still don't know what to do
>


Remember that the c# executable must reside on a local drive when
running it.
Managed applications which are run from the network have several
security restrictions, e.g. they are not allowed to access the file system.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
offset method problem Axel Microsoft Excel Programming 4 9th Apr 2010 05:40 PM
Problem with .navigate method NoSpam@aol.com Microsoft Excel Programming 0 20th Mar 2006 03:33 AM
Strange IsReady results from DriveInfo greg.merideth@gmail.com Microsoft C# .NET 0 7th Dec 2005 04:49 PM
method Fill - problem Pawel Blochowiak Microsoft ASP .NET 3 16th Mar 2005 01:36 AM
Inheritance problem - Base Class method being called when Derived Class method should be called. Jeff Molby Microsoft VB .NET 3 6th Mar 2005 11:03 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:29 PM.