I want to upload multiple documents with same metadata.i have created a custom webpart with my metadata and fileupload controls. On click of ok button all the uploaded documents (from fileupload controls) will be added to the document library with metadata.
Am using below function to add the documents to document library.I will call below function for each fileupload control.
private static void insert(SPList docLibrary, FileUpload Fu)
{
Stream fStream = Fu.PostedFile.InputStream;
byte[] contents = new byte[fStream.Length];
fStream.Read(contents, 0, (int)fStream.Length);
fStream.Close();
SPFile destFile = docLibrary.RootFolder.Files.Add(docLibrary.RootFolder.Url + "/" + Fu.FileName, contents, true);
SPListItem destItem = destFile.Item;
destItem.File.CheckIn(string.Empty, SPCheckinType.MinorCheckIn);
}
If I add same same document to 2 file upload controls then first file is getting added properly but for 2nd file am getting “file must be checked out ” error. Any idea what can be the issue ?
private static void insert(SPList docLibrary, FileUpload Fu)
{
Stream fStream = Fu.PostedFile.InputStream;
byte[] contents = new byte[fStream.Length];
fStream.Read(contents, 0, (int)fStream.Length);
fStream.Close();
SPFile destFile = docLibrary.RootFolder.Files.Add(docLibrary.RootFolder.Url + "/" + Fu.FileName, contents, true);
SPListItem destItem = destFile.Item;
destItem.File.CheckIn(string.Empty, SPCheckinType.MinorCheckIn);
}
If I add same same document to 2 file upload controls then first file is getting added properly but for 2nd file am getting “file must be checked out ” error. Any idea what can be the issue ?