Click here to Skip to main content
15,894,337 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I have a Silverlight application ,I attache some file such as image or excel or word document as a array in database , and then show them with these codes in client system, it works when I run it on visual studio but when I publish my project and run it on iis or on a web, It dose not show attached file can any body help me?
thanks
C#
try
          {
              System.IO.Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\CImage");

          }
          catch (Exception ex)
          {
          }

              try
              {
                  System.IO.File.WriteAllBytes(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\CImage\\" + (e.Result.Last().NameFile .ToString().Trim()) + "-" + (e.Result.Last().Id.ToString().Trim()) + "." + (e.Result.Last().Format.ToString().Trim()), e.Result.Last().FileAttach );

              }
              catch (Exception ex)
              {
              }

          try
          {
              dynamic shell = AutomationFactory.CreateObject("Shell.Application");
              shell.ShellExecute(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\CImage\\" + (e.Result.Last().NameFile.ToString().Trim()) + "-" + (e.Result.Last().Id.ToString().Trim()) + "." + (e.Result.Last().Format.ToString().Trim()));

          }
          catch (Exception ex)
          {
              return;
          }
Posted
Updated 14-Oct-14 3:46am
v2
Comments
Dominic Burford 14-Oct-14 10:10am    
Personally I always try to read / write files to the user's TEMP folder.

string tempFolder = Path.GetTempPath();

As an aside, I place all my namespaces at the top of my code so that I don't clutter my code with the full path i.e. System.IO should be included at the top of your code file so that you don't need to keep referring to it repeatedly throughout your code.
Angela 10293848 15-Oct-14 1:44am    
Hicould you explain more your idea , or by some snap code plz?

1 solution

You are accessing the MyDocuments folder, which is a SpecialFolder. You cannot access the folder in normal mode, only trusted applications with elevated privilege can access such type of special folder.

Please check your permissions and try again. If it is anything else, I'm out of my depth :)
 
Share this answer
 
Comments
Angela 10293848 15-Oct-14 3:13am    
HiI folowed this page to make trusted app http://msdn.microsoft.com/en-us/library/gg192793(v=vs.95).aspx
but still id does not work in browser

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900