Recent Posts

Tuesday, August 18, 2015

Cannot implicitly convert type 'Google.Apis.Drive.v2.Data.File' to 'System.IO.File' - Resolved Code

I was using Google Drive API go get File Name of the stored file in Google drive

Although following the sample code provided by Google I encountered following error:

Cannot implicitly convert type 'Google.Apis.Drive.v2.Data.File' to 'System.IO.File'. I was surprised to find there were not much written about this.

I thought it would be a small but helpful post to some. Instead of wasting  precious time you can just do following to resolve this issue:

  1. If you are using System.IO in your program, then it will first pickup System.IO.File and ignore the Google.Apis.Drive.v2.Data.File.
  2. Therefore to resolve this issue you need to give full path of the Google Drive File
  • For Eg:
        Google.Apis.Drive.v2.Data.File file = service.Files.Get(fileId).Execute();
            Console.WriteLine("Title: " + file.Title);
              Console.WriteLine("Description: " + file.Description);
                Console.WriteLine("MIME type: " + file.MimeType);

        Hope this helps, Enjoy coding guys........

        Related Posts by Categories

        No comments:

        Post a Comment