tags:

views:

91

answers:

2

I have made a application that can copy files to places in two TreeViews and that has to map your C:. But my father, an experienced programming, said that if the program goes wrong, it could mess up the whole C: of my consumers (I will be publishing this, it is not already out). And as a user, you have to run as admin. How do I make the copy and delete transactions safer (I already have a "Are you sure you want to delete the files?" MessageBox). And how do I make it so that everyone has permission to browse the C:?


Aparently this line of code give me an "UnauthorizedAccessException "
DirectoryInfo[] dirSubs = dir.GetDirectories();

+3  A: 

You can do a simple Ok/Cancel or Yes/No prompt using the MessageBox class (see link for sample code).

As for checking permissions I think you want Directory.GetAccessControl. It should be able to tell you if your destination path is writable.

Parappa
+1  A: 

All a prompt does is give the user a dialog to respond to. Whether it's safe or not depends entirely on your code. For the permissions, you can't make it so everyone has rights to browse everything, even if they're running as admin. Some folders (like those created by System Restore) do not give access to Admin users without specifically editing the folder permissions.

What safety stuff you need or can add depends largely on what its purpose is.

CodeByMoonlight