> private static void CreateDocumentItem(SPList DocumentLibrary,
> string ItemName, string FilePath, string FileRef,string DocId,string
> ParentFolder)
> {
> var ParentURL = string.Empty;
> if (!DocumentLibrary.ParentWebUrl.Equals("/"))
> {
> ParentURL = DocumentLibrary.ParentWebUrl;
> }
> SPSecurity.RunWithElevatedPrivileges(delegate
> {
> using (var site = new SPSite(DocumentLibrary.ParentWeb.Url))
> {
> using (SPWeb web = site.OpenWeb())
> {
> Hashtable propertiesHash = new Hashtable
> {
> {"EYDocID",DocId}
> };
> byte[] strm = File.ReadAllBytes(FilePath);
> DocumentLibrary.RootFolder.Files.Add(ParentURL + FileRef + "/" + ParentFolder + "/" + ItemName, strm, propertiesHash, false);
> web.AllowUnsafeUpdates = false;
> }
> }
> });
>
> }`