//save shapes to local document public void SaveShapes(List <Shape> shapes) { const string CONTENT_TYPE = "application/octet-stream"; FileStream fileStream = new FileStream(FILE_NAME, FileMode.Create); BinaryFormatter binaryFormatter = new BinaryFormatter(); binaryFormatter.Serialize(fileStream, shapes); fileStream.Close(); _fileList = _service.ListRootFileAndFolder(); if (_fileList.Exists(file => file.Title == FILE_NAME)) { Google.Apis.Drive.v2.Data.File foundFile = _fileList.Find(item => { return(item.Title == FILE_NAME); }); _service.UpdateFile(FILE_NAME, foundFile.Id, CONTENT_TYPE); } else { _service.UploadFile(FILE_NAME, CONTENT_TYPE); } }
//click save private void ClickSaveButton(object sender, EventArgs e) { Bitmap bitmap = new Bitmap(_panel.Width, _panel.Height); _panel.DrawToBitmap(bitmap, new Rectangle(0, 0, _panel.Width, _panel.Height)); bitmap.Save(FILENAME); const string CONTENT_TYPE = "image/jpeg"; List <Google.Apis.Drive.v2.Data.File> fileList = _service.ListRootFileAndFolder(); Google.Apis.Drive.v2.Data.File foundFile = fileList.Find(item => { return(item.Title == FILENAME); }); int exist = fileList.FindIndex(item => { return(item.Title == FILENAME); }); if (exist != -1) { _service.UpdateFile(FILENAME, foundFile.Id, CONTENT_TYPE); } else { _service.UploadFile(FILENAME, CONTENT_TYPE); } }