Hi All
Upload programatically multiple file with same name in doc lib then it shoud not replace the old one. It should create the new entry?
Below is my code, If file is existing with same name then its replacing the old one.
But I want to create the new entry with increment ID.
protected
void btnUpload_Click(object sender, EventArgs e)
{
if (fileUpload.HasFile)
{
if (fileUpload.PostedFile.ContentLength > 0)
{
string fileName = fileUpload.FileName;
using (SPWeb oWeb = siteUrl.OpenWeb())
{
oWeb.AllowUnsafeUpdates =
true;
SPDocumentLibrary docLib = oWeb.Lists["ETS-DocFile"] as SPDocumentLibrary;
string fileExtension = fileUpload.FileName.Substring(fileUpload.FileName.IndexOf("."));
byte[] fileByte = fileUpload.FileBytes;
string destUrl = fileName + fileExtension;
SPFile destFile = docLib.RootFolder.Files.Add(destUrl, fileByte, true);
destFile.Update();
oWeb.AllowUnsafeUpdates =
false;
}
}
}