Search code examples
c#.netgoogle-docsgoogle-docs-api

Upload string contents into google doc


I wanna know if I can create a doc on google docs without uploading document.. I just want to pass the value of a textbox from my c# windows application and store it onto the google docs server.. I don't want to create any intermediate file to upload on google docs.. I'm storing the textbox data in ms access database and I want it to be saved at google docs too..


Solution

  • Try with the following code:

    DocumentsService service = new DocumentsService("MyApp");
    
    // TODO: Authorize the service object
    
    Stream stream = new MemoryStream(ASCIIEncoding.Default.GetBytes("This is the document content"));
    
    DocumentEntry entry = service.Insert(new Uri(DocumentsListQuery.documentsBaseUri), stream, "text/plain", "Document title") as DocumentEntry;