Save A Google Docs Document As A File In .NET


Given a DocumentEntry, save to local file "C:\example.html"
Uri documentUri = new Uri(entry.Content.AbsoluteUri);
Stream stream = service.Query(documentUri);
StreamReader streamReader = new StreamReader(stream);
StreamWriter streamWriter = new StreamWriter("C:\\example.html");
string line = "";
while( (line = streamReader.ReadLine()) != null) {
    streamWriter.WriteLine(line);
}
streamReader.Close();
streamWriter.Close();

7 comments:

VHanded Cheepeng said...

I am using your method to download a Doc file from my Google Doc account, but the images in the Doc file went missing.

Currently use the new v1.5 .Net client, and noticed the DocumentsRequest.Download() method.

However, it request parameter of Document, so how do I pass in DocumentEntry?


Thanks!

Quân Đào said...
This comment has been removed by the author.
Quân Đào said...
This comment has been removed by the author.
Quân Đào said...
This comment has been removed by the author.
Quân Đào said...
This comment has been removed by the author.
Quân Đào said...
This comment has been removed by the author.
Quân Đào said...
This comment has been removed by the author.