Uploading file with metadata

Posted by Dilse Naaz on Stack Overflow See other posts from Stack Overflow or by Dilse Naaz
Published on 2010-04-29T09:55:09Z Indexed on 2010/04/29 9:57 UTC
Read the original article Hit count: 380

Filed under:
|
|
|
|

Hi

Could you help me for how to adding a file to the sharepoint document library? I found some articles in net. but i didn't get the complete concept of the same. Now i uploaded a file without metadata by using this code.

if (fuDocument.PostedFile != null)
                {
                    if (fuDocument.PostedFile.ContentLength > 0)
                    {
                        Stream fileStream = fuDocument.PostedFile.InputStream;
                        byte[] byt = new byte[Convert.ToInt32(fuDocument.PostedFile.ContentLength)];
                        fileStream.Read(byt, 0, Convert.ToInt32(fuDocument.PostedFile.ContentLength));
                        fileStream.Close();


                        using (SPSite site = new SPSite(SPContext.Current.Site.Url))
                        {
                            using (SPWeb webcollection = site.OpenWeb())
                            {
                                SPFolder myfolder = webcollection.Folders["My Library"];
                                webcollection.AllowUnsafeUpdates = true;
                                myfolder.Files.Add(System.IO.Path.GetFileName(fuDocument.PostedFile.FileName), byt);

                            }
                        }
                    }
                }

This code is working as fine. But i need to upload file with meta data. Please help me by editing this code if it possible. I created 3 columns in my Document library..

© Stack Overflow or respective owner

Related posts about sharepoint

Related posts about c#