troubleshooting Question

How to attach file to the List in Sharepoint

Avatar of mohan21_kumar
mohan21_kumar asked on
Microsoft IIS Web ServerWindows Server 2003
4 Comments1 Solution4629 ViewsLast Modified:
Hi Experts,
   I'm new to sharepoint, I have a requirement where i have to attach a file to the List. I have tried to attach the file to the List using C#. But i'm getting Access denined as error message.
   I have written the following code to attach the file to the List. But i dont know how to give write permission to the Users
  I have enabled the anonymous access for the site in Central admin.

  Is there any other place where i have provide the permission or is it possible to provide permission to the User programmatically?

Please help me how to solve this or suggest me some URL or send me some sample code which would help me in solve this problem.

Thanks in advance
                        SPWeb web = SPContext.Current.Web;
                        web.AllowUnsafeUpdates = true;
                        SPList list = SPContext.Current.Web.Lists["spforums_posts"];
                        SPListItem listItem = list.Items[0];
                        string FileNameSave = MsgeInId + "_" + _btnUpload.FileName.ToString();
                        listItem.Attachments.Add(FileNameSave, _btnUpload.FileBytes);
                        web.AllowUnsafeUpdates = false;
                    catch(Exception Ex)
                        Page.Response.Write("<center>" + Ex.Message.ToString() + "</Center>");
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 4 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros