Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

up vote 0 down vote accepted

I have figured out this problem. Since we not using the default method for uploading the document to the document library we have to use custom document library for this purpose. I have used custom task form in order to upload the document to the document library and so the document library also has to be custom document library. Hope this helps someone.

Thanks

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.