sharepoint online – How to overwrite the version of a file using CSOM?

When I register as a main version or a secondary version, I create the new version as main. Below is the code:

static void private file UploadFiles (string sourceFileUrl, Folder targetFolder, string fileName, ClientContext clientContext, ClientContext destinationContext, bool bolMajorVersion)
{

FileCreationInformation targetFileVersionCreationInfo = new FileCreationInformation ();
targetFileVersionCreationInfo.Overwrite = true;
try
{
Web request request = HttpWebRequest.Create (sourceFileUrl);
request.Credentials = clientContext.Credentials;
using (response from WebResponse = request.GetResponse ())
{
using (Stream Stream = response.GetResponseStream ())
{
byte[] verBuffer = new byte[32768];
using (MemoryStream versionMS = new MemoryStream ())
{
Int read
while ((read = stream.Read (seeBuffer, 0, seeBuffer.Length))> 0)
{
versionMS.Write (seeBuffer, 0, read);
}
versionMS.Seek (0, SeekOrigin.Begin);
targetFileVersionCreationInfo.ContentStream = versionMS;
destinationContext.RequestTimeout = System.Threading.Timeout.Infinite;
targetFileVersionCreationInfo.Url = targetFolder.ServerRelativeUrl + "/" + fileName;
Microsoft.SharePoint.Client.File targetVersionFile = targetFolder.Files.Add (targetFileVersionCreationInfo);

File Microsoft.SharePoint.Client.File = targetVersionFile;
// Checkout if you are registered
destinationContext.Load (file);

destinationContext.ExecuteQuery ();

if (file.CheckOutType == CheckOutType.None)
{
file.CheckOut ();
}
// ListItem lstItem = file.ListItemAllFields;
//clientContext.Load(lstItem);
//clientContext.ExecuteQuery ();
yes (bolMajorVersion)
{

file.CheckIn ("Uploaded through the portal", CheckinType.MajorCheckIn);

}
plus
{
// Overwrite to avoid creating a new version.
file.CheckIn ("Uploaded through the portal", CheckinType.MinorCheckIn);
}
destinationContext.ExecuteQuery ();
// destinationContext.ExecuteQuery ();





}
}
}
}
catch (ex exception)
{
// handle the exception
}
}

The file is initially loaded with version 0.1 after registering as a major version, creating a new version 1.0 and also maintaining version 0.1. I need to overwrite this file from version 0.1.

Any help should be appreciated.