예제 #1
0
        public Stream Read(string filePath)
        {
            var          file         = GDriveHelper.GetFileByPath(filePath);
            var          request      = service.Files.Get(file.FileId);
            MemoryStream memoryStream = new MemoryStream();

            request.Download(memoryStream);
            return(memoryStream);
        }
예제 #2
0
        public void Rename(string filePath, string newFileName)
        {
            var file = GDriveHelper.GetFileByPath(filePath);

            Google.Apis.Drive.v3.Data.File gfile = new Google.Apis.Drive.v3.Data.File()
            {
                Name = newFileName
            };
            var updateRequest = service.Files.Update(gfile, file.FileId);

            updateRequest.Fields = "name";
            updateRequest.Execute();
        }
예제 #3
0
        public void MoveTo(string sourceFilePath, string destiFilePath)
        {
            var             file            = GDriveHelper.GetFileByPath(sourceFilePath);
            var             updateRequest   = service.Files.Update(new Google.Apis.Drive.v3.Data.File(), file.FileId);
            GDriveDirectory gDriveDirectory = new GDriveDirectory();

            if (!gDriveDirectory.Exists(destiFilePath))
            {
                throw new DirectoryNotFoundException(destiFilePath + " does not exists");
            }

            var tree       = GDriveHelper.GetFolderTree(destiFilePath);
            var lastFolder = GDriveHelper.GetLastFolderInTree(tree);

            updateRequest.AddParents    = lastFolder.FileId;
            updateRequest.RemoveParents = file.File.Parents[0];
            updateRequest.Execute();
        }
예제 #4
0
 public bool Exists(string filePath)
 {
     return(GDriveHelper.GetFileByPath(filePath) != null);
 }
예제 #5
0
        public void Delete(string filePath)
        {
            var file = GDriveHelper.GetFileByPath(filePath);

            service.Files.Delete(file.FileId);
        }
예제 #6
0
        //TODO: Implement destiFilePath
        public void CopyTo(string sourceFilePath, string destiFilePath)
        {
            var file = GDriveHelper.GetFileByPath(sourceFilePath);

            service.Files.Copy(file.File, "");
        }