Sunday, November 23, 2008

How to upload document into document library using C#.Net

String Continent = clistitem["Continent"].ToString();
fStream = FileUpload1.PostedFile.InputStream;
fStream.Read(contents, 0, (int)fStream.Length);


//storing the contents of the uploaded document
Bytes[] contents= new byte[fStream.Length];
fileName = FileUpload1.PostedFile.FileName.Substring(FileUpload1.PostedFile.FileName.LastIndexOf('\\') + 1);

Hashtable ht = new Hashtable();
ht.Add("Continent", Continent);
SPFile fff = files.Add(fileName, contents, ht, true);
myweb.AllowUnsafeUpdates = true;

No comments: