locked
File operation not permitted. Access to path is denied RRS feed

  • Question

  • hi friends,

    i have images folder in clientbin and i am using wcf webserivce to get images path dynamically. i got image path using webservice but when i tried to open images folder i am getting error "File operation not permitted. Access to path is denied".


    what is the easiest way to do.


    Thank you

     kranthi

    Sunday, February 13, 2011 6:20 AM

Answers

  • Assume your WCF service returns an image bytes arrry,  you can convert the bytes to BitmapImage in the service call complected function:

    YourService_Completed(sender, e)
    {

    byte[] YourImageByteArray = e.Result;

    BitmapImage img = new BitmapImage();

    using (MemoryStream stream = new MemoryStream(YourImageByteArray))

    {

          img.SetSource(stream);

    }


    }

    Then you can use this BitmapImage as an Image control source.


    Monday, February 14, 2011 11:19 AM
  • as you said that you are getting bytes of array from the database for image, then send this bytes to silverlight application.

    In silverlight applicaiton

    1. give it to stream

    2. stream to BitmapImage

    3. BitmapImage to ImageBrush

    4. ImageBrush to stackpanel background

    No need of taking Image control, you can show the images by making it stackpanel background.

    Tuesday, February 15, 2011 12:13 AM

All replies

  • You cannot access folder in Sl due to security reason. You need to use as OOB or use the isolated storage.

    using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication())
                { 
                    using(IsolatedStorageFileStream isfStream = new IsolatedStorageFileStream(filePath,FileMode.Create,isf))
                    {
                        using(StreamWriter writer = new StreamWriter(isfStream))
                        {
                            writer.Write(data);                        
                        }
                    }
                }

    Sunday, February 13, 2011 6:36 AM
  • Are you trying to read the image from silverlight project ?, No, you cannot read the files/images from silverlight project.

    But another option is to read the files/images from webapplication and convert it into stream then to bytes and send the bytes to silvelright project, In silverlight project use bytes to display the image.

    Sunday, February 13, 2011 7:49 AM
  • What are you actually trying to do?

    Sunday, February 13, 2011 8:27 AM
  • how is issue going on?

    Monday, February 14, 2011 12:39 AM
  • thx very much for your reply. i am very new to silverlight. i am using wcf webservice to get the path of images. what is the best way to do it i mean to convert bytes and to image?

    Monday, February 14, 2011 11:10 AM
  • Assume your WCF service returns an image bytes arrry,  you can convert the bytes to BitmapImage in the service call complected function:

    YourService_Completed(sender, e)
    {

    byte[] YourImageByteArray = e.Result;

    BitmapImage img = new BitmapImage();

    using (MemoryStream stream = new MemoryStream(YourImageByteArray))

    {

          img.SetSource(stream);

    }


    }

    Then you can use this BitmapImage as an Image control source.


    Monday, February 14, 2011 11:19 AM
  • as you said that you are getting bytes of array from the database for image, then send this bytes to silverlight application.

    In silverlight applicaiton

    1. give it to stream

    2. stream to BitmapImage

    3. BitmapImage to ImageBrush

    4. ImageBrush to stackpanel background

    No need of taking Image control, you can show the images by making it stackpanel background.

    Tuesday, February 15, 2011 12:13 AM