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

  • Question

  • Hello,

    I have created Silverlight application & downloading some assmebly parts real time. Now want to check its already in InternetCache or not before downloading, I have added this code. 

    string tempFile = Environment.GetFolderPath(Environment.SpecialFolder.InternetCache) + "\\LM.zip";
              

    But its give me error "File operation not permitted. Access to path '' is denied" so how can I solve it ?

    Thanks in advance
    Laxmilal

    Thursday, August 19, 2010 2:09 AM

Answers

  • I don't think it's possible to show a custom progress indicator for the library caching. So having a custom download mechanism may not be the worst idea. However, I really suggest you use isolated storage for that. Sure, you need to ask the user for an increase of the quota. But there are two problems when you try to use the browser cache.

    The first you've already come across - security issues when you try to check for your file. Also, even if it was possible to check the cache folder, you wouldn't find your file in most cases, as most browsers do not store the original file names there, but files with generated ids. There won't be a "LM.zip" entry there, even if the file is cached.

    And another problem is that the default cache sizes of most browsers are low, like 50 MiB. That means that your 10 MiB file will be removed from the cache after a bit of surfing pretty quickly, and then it would have to be downloaded again, even if it didn't change at all.

    So again, I strongly suggest isolated storage if you want to do that.

    Thursday, August 19, 2010 3:31 AM

All replies

  • Hi Laxmilal,

    this operation is not allowed due to security restrictions. May I ask why you're downloading your additional assembly parts manually? If you're using the built-in application library caching feature the runtime would do all that for you automatically. If you still need to download assemblies manually, you need to put them into isolated storage.

    Thursday, August 19, 2010 2:41 AM
  • Thanks for answer, Let me explain my issue ...

    I have created a application which have 10 MB zip file. I do need this after just my application start. Thats why I have enabled Application Library Caching & Move the 10MB source to Another library. 

    Now XAP is downloaded fatser, but this 10 mb file take some time in download.

    XAP download shows me some progress and after completion of xap, Silverlight downloader is start Downlaod of Application Library files, Its does't show me any progress, just display some Animated Circle.

    So  I want to dispaly proper progress for all downloads. What can I do ?

    I have tried the Silverlight Splash screen but it only works for XAP, after that no progress display. 

    So what is workarround for this ? Please let me know. 

    I can use ISOLated Stogare but its not save all the data if it increase, I also need to prompt to user to increase QUOTA, but it will not help if user disaggree it.

    Please let me know how to show good progress to user using Application library caching.

    Thanks in advance
    Laxmilal Menaria


    Thursday, August 19, 2010 3:05 AM
  • Hi Imenaria,

    Silverlight works in restricted environment on the client machine. So u need to use Isolated store freature of Silverlight to accomplise ur task. here code for that:

     string filePath = "Greetings.txt";
                string data = "Hello World!";
    
                using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication())
                { 
                    using(IsolatedStorageFileStream isfStream = new IsolatedStorageFileStream(filePath,FileMode.Create,isf))
                    {
                        using(StreamWriter writer = new StreamWriter(isfStream))
                        {
                            writer.Write(data);                        
                        }
                    }
                }


    Similarly to read, repalce StreamWriter with StreamReader &  use Read() method of StreamReader.

    Thursday, August 19, 2010 3:14 AM
  • I don't think it's possible to show a custom progress indicator for the library caching. So having a custom download mechanism may not be the worst idea. However, I really suggest you use isolated storage for that. Sure, you need to ask the user for an increase of the quota. But there are two problems when you try to use the browser cache.

    The first you've already come across - security issues when you try to check for your file. Also, even if it was possible to check the cache folder, you wouldn't find your file in most cases, as most browsers do not store the original file names there, but files with generated ids. There won't be a "LM.zip" entry there, even if the file is cached.

    And another problem is that the default cache sizes of most browsers are low, like 50 MiB. That means that your 10 MiB file will be removed from the cache after a bit of surfing pretty quickly, and then it would have to be downloaded again, even if it didn't change at all.

    So again, I strongly suggest isolated storage if you want to do that.

    Thursday, August 19, 2010 3:31 AM
  • Thanks.

    Thursday, August 19, 2010 4:04 AM