コード例 #1
0
        public async Task DoDownload(string FileName, string PathForDownload = null, string FileID = "")
        {
            GoogleServiceController GSC = new GoogleServiceController();
            DriveService            DS  = GSC.GetDriveService();
            DriveController         dc  = new DriveController(DS);
            string OnlyFileName         = AuxFileCommCenter.GetFileNameOnlyWithFormat(FileName)[0];

            if (string.IsNullOrEmpty(FileID))
            {
                //Find the file
                Dictionary <string, string> FilesInDrive = dc.FindFiles(false);
                FileID = FilesInDrive.Where(x => x.Value == OnlyFileName).First().Key;
            }

            if (!string.IsNullOrEmpty(FileID))
            {
                if (string.IsNullOrEmpty(PathForDownload))
                {
                    await dc.DownloadFile(FileID, FileName);
                }
                else
                {
                    await dc.DownloadFile(FileID, FileName, PathForDownload);
                }
            }
            else
            {
                Console.WriteLine("O Arquivo não foi localizado, abortando a operação.");
            }
        }