>using System; >using System.Collections.Generic; >using System.Linq; >using System.Net; >using System.Windows; >using System.Windows.Controls; >using System.Windows.Documents; >using System.Windows.Input; >using System.Windows.Media; >using System.Windows.Media.Animation; >using System.Windows.Shapes; >using System.Runtime.InteropServices.Automation; > >namespace SL4Com >{ > public partial class MainPage : UserControl > { > public MainPage() > { > InitializeComponent(); > } > > private void btnInstall_Click(object sender, RoutedEventArgs e) > { > if (Application.Current.InstallState == InstallState.NotInstalled) > Application.Current.Install(); > } > > private void btnWriteFile_Click(object sender, RoutedEventArgs e) > { > using (dynamic fsoCom = AutomationFactory.CreateObject("Scripting.FileSystemObject")) > { > dynamic file = fsoCom.CreateTextFile(@"c:\test.txt", true); > file.WriteLine("Bloody Hell"); > file.WriteLine("Silverlight 4"); > file.Close(); > > } > } > } >} > >>This sample is a simple Out-of-Browser example and in the VS2010 Express IDE it works , a OOB window appears and the file is generated when the button is clicked.
>Webpage error details > >User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; .NET4.0E) >Timestamp: Tue, 24 Aug 2010 01:37:42 UTC > >Message: Unhandled Error in Silverlight Application This operation is not supported in the current context. at MS.Internal.Error.MarshalXresultAsException(UInt32 hr, COMExceptionBehavior comExceptionBehavior) > at MS.Internal.XcpImports.CheckHResult(UInt32 hr) > at MS.Internal.ComAutomation.ComAutomationNative.CreateObject(String progID, IntPtr& nativeObject) > at MS.Internal.ComAutomation.ComAutomationServices.CreateObject(String progID, ComAutomationParamWrapService paramWrapService) > at System.Runtime.InteropServices.Automation.AutomationFactory.CreateObject(String progID) > at SL4Com.MainPage.btnWriteFile_Click(Object sender, RoutedEventArgs e) > at System.Windows.Controls.Primitives.ButtonBase.OnClick() > at System.Windows.Controls.Button.OnClick() > at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e) > at System.Windows.Controls.Control.OnMouseLeftButtonUp(Control ctrl, EventArgs e) > at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName) >Line: 1 >Char: 1 >Code: 0 >URI: file:///C:/VS2010/Silverlight/SL4Com/SL4Com/Bin/Debug/SL4ComTestPage.html > >>
<OutOfBrowserSettings.SecuritySettings>
<SecuritySettings ElevatedPermissions="Required"/>
</OutOfBrowserSettings.SecuritySettings>
Even then I think you're limited to where you can write: