I am uploading a document in the document library using the following code.
Hashtable objhash = new Hashtable();
objhash.Add("List ID", ListIDNo);
//
try
{
if (FileUpload1.PostedFile != null)
{
if (FileUpload1.PostedFile.ContentLength > 0)
{
//
Stream filestream = FileUpload1.PostedFile.InputStream;
byte[] byt = new byte[Convert.ToInt32(FileUpload1.PostedFile.ContentLength)];
filestream.Read(byt, 0, Convert.ToInt32(FileUpload1.PostedFile.ContentLength));
filestream.Close();
using (SPSite site = new SPSite(SPContext.Current.Site.Url))
{
using (SPWeb webcollection = site.OpenWeb())
{
SPFolder myfolder = webcollection.Folders["Contract Forms"];
webcollection.AllowUnsafeUpdates = true;
//myfolder.Files.Add(System.IO.Path.GetFileName(FileUpload1.PostedFile.FileName), byt, objhash, false);
SPFile file;
file = myfolder.Files.Add(System.IO.Path.GetFileName(FileUpload1.PostedFile.FileName), byt,objhash, false);
myfolder.Update();
file.Item.SystemUpdate(false);
This works fine when we upload the document to the Document Library. When the document is uploaded the version shows as 0.1 and when the item is edited and add some fields into it the version changes as 0.2. Whenever i click edit and save it the version is updated. I want the version to change only when i edit the document. while uploading the document i am also updating a field in the document library using hash table. Any Ideas ?
Thanks