Skip to main content

Microsoft Silverlight

Answered Question How to create text file in silverlight (In server side)RSS Feed

(0)

vrrengas123
vrrengas123

Member

Member

0 points

4 Posts

How to create text file in silverlight (In server side)

Hi,

           How to create the text file in server side with specified path. In which I want to store the error log information.

 

With Regards

Renganathan.R 

 

prujohn
prujohn

Contributor

Contributor

3567 points

703 Posts

Re: How to create text file in silverlight (In server side)

Use the System.IO.File namespace to Create/Read/Update/Delete your files. You can use HostingEnvironment.ApplicationPhysicalPath to get the root path of your web app, and then create directories/files from there (assuming you have set permissions). Then setup a web service, to receive the log events from Silverlight client(s).

vrrengas123
vrrengas123

Member

Member

0 points

4 Posts

Re: How to create text file in silverlight (In server side)

Hi Jhon

               FileStream f = System.IO.File.Create(Application.Current.Host.Source.AbsolutePath + "\\tex.txt");              Byte[] info = new System.Text.UTF8Encoding(true).GetBytes("This is some text in the file.");

              f.Write(info, 0, info.Length);

              f.Close();

             Application.Current.Host.Source.AbsolutePath It returns "Clientbin\*****.xap". But I needed the current hosting path. and also without consuming the webservices I need to write the log information into that file.

 

 

Amanda Wang - MSFT
Amanda W...

All-Star

All-Star

17241 points

1,466 Posts

Answered Question

Re: How to create text file in silverlight (In server side)

 Hi Renganathan,

Due to Silverlight runs on client side, if you want to create a fine in the silverlight,  the file will be created on the client machine.

So if you want to create a file in your server you need a Web Service or WebClient.OpenWrite function + ASPX page or IHttpHandler to do that.

You can try to refer the discussion about this here:  http://silverlight.net/forums/t/22456.aspx

Amanda Wang
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities