File drag and drop in in-browser app
-
I have an SL 5 app that the user can drop files and directories into. When launched from the debugger, it works as expected. When I try to use the xap in a page on a remote site, I get a Security exception. foreach (FileInfo fi in files) { // _files.Enqueue(fi); if (fi.Attributes == FileAttributes.Directory) Attaching the debugger to the browser, I see: +fi.Attributes 'fi.Attributes' threw an exception of type 'System.Security.SecurityException' System.IO.FileAttributes {System.Security.SecurityException} "File operation not permitted. Access to path '' is denied." UPDATE: Some properties of the FileInfo object are available, but not things like Attributes, Directory, DirectoryName. 1) Why does it work when started from the debugger? 2) How can I get it working outside of the debugger? Thanks for any insight....
-
I have an SL 5 app that the user can drop files and directories into. When launched from the debugger, it works as expected. When I try to use the xap in a page on a remote site, I get a Security exception. foreach (FileInfo fi in files) { // _files.Enqueue(fi); if (fi.Attributes == FileAttributes.Directory) Attaching the debugger to the browser, I see: +fi.Attributes 'fi.Attributes' threw an exception of type 'System.Security.SecurityException' System.IO.FileAttributes {System.Security.SecurityException} "File operation not permitted. Access to path '' is denied." UPDATE: Some properties of the FileInfo object are available, but not things like Attributes, Directory, DirectoryName. 1) Why does it work when started from the debugger? 2) How can I get it working outside of the debugger? Thanks for any insight....
Have you tried running as normal and then attaching to the process? This may give you the details of the exception and then you would understand why.
Computers have been intelligent for a long time now. It just so happens that the program writers are about as effective as a room full of monkeys trying to crank out a copy of Hamlet.
-
Have you tried running as normal and then attaching to the process? This may give you the details of the exception and then you would understand why.
Computers have been intelligent for a long time now. It just so happens that the program writers are about as effective as a room full of monkeys trying to crank out a copy of Hamlet.
-
The OP contains the exception I see when attaching the debugger to the browser. Certain properties of the FileInfo appear to be unavailble -- Attributes, Directory, DirectoryName -- when running outside of the browser.
It seems what ever the silverlight app is running under does not have such permissions for the locations you are hitting then. When you run using the debugger you are running with elevated privileges.
Computers have been intelligent for a long time now. It just so happens that the program writers are about as effective as a room full of monkeys trying to crank out a copy of Hamlet.
-
It seems what ever the silverlight app is running under does not have such permissions for the locations you are hitting then. When you run using the debugger you are running with elevated privileges.
Computers have been intelligent for a long time now. It just so happens that the program writers are about as effective as a room full of monkeys trying to crank out a copy of Hamlet.
As Colin mentioned (sort of :)), this is Silverlight. It runs in a locked down sandbox environment and does not have access to local resources (files, registry, etc.). If you want to have access to those types of things, you need to specify that you want elevated permisions in your config file.
-
As Colin mentioned (sort of :)), this is Silverlight. It runs in a locked down sandbox environment and does not have access to local resources (files, registry, etc.). If you want to have access to those types of things, you need to specify that you want elevated permisions in your config file.
Thanks for the reply. A hint on how to specify the elevated permissions would be appreciated... (Weird: when I build and run the project -- from the debugger -- on a different computer, the app does not have elevated permission. Trying to figure out the difference between the two computers. I have this code in a handler for the MainPage Loaded event:
Msgs.Text = string.Format("{0} ElevatedPermissions", (Application.Current.HasElevatedPermissions ? "Has" : "Does NOT have"));
)