为什么在谷歌驱动器插入文件夹两次 [英] why inserting folder in google drive twice

查看:216
本文介绍了为什么在谷歌驱动器插入文件夹两次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的vb.net应用程序中,我设法创建文件夹和子文件夹,文件,但我的问题是当我创建子文件夹,文件(在文件夹父),我发现我的子文件夹在驱动器和父文件夹(我发现它是两次,我只希望它在文件夹父)

In my application with vb.net , i managed to create folder and subfolder , file , but my problem is when i create subfolder ,file (in folder parent) , i found my subfolder in drive and in folder parent (i found it twice and i want it only in folder parent )

这是我的代码

Public Function subfolder_creation(id_sub As String) As String
    Dim subfolder As New Google.Apis.Drive.v2.Data.File()
    subfolder.Title = VF.Text

    subfolder.MimeType = "application/vnd.google-apps.folder"
    Dim ref = Service.Files.Insert(subfolder)
    MessageBox.Show("sous dossier crée")
    ref.Fields = "id"
    Dim a = ref.Execute()
    MessageBox.Show(" Id Subfolder  " & a.Id)
    Dim reference = New ParentReference()
    reference.Id = id_sub
    Dim insert = Service.Parents.Insert(reference, a.Id).Execute
    MessageBox.Show("Création sous dossier avec succés")
    Dim reference_file = New ParentReference()
    reference_file.Id = a.Id
    UploadFile(reference_file.Id)
    Return (a.Id)

我知道问题来自两个插入指令,但我不知道如何解决它

i know the problem is from two insert instruction , but i don't know how i solve it

推荐答案

我无法测试vb,但您应该可以在一个请求中完成所有操作。

I cant test vb but you should be able to do it all in one request

Dim subfolder As New Google.Apis.Drive.v2.Data.File()
subfolder.Title = VF.Text
subfolder.Parents = parentFolderId
subfolder.MimeType = "application/vnd.google-apps.folder"

将父项添加到子文件夹插入的正文中。从理论上讲,您应该可以修补程序将子文件夹与父文件插入后,但它的过度杀死国际海事组织。只需插入即可。

Add the parent to the body of the insert of the sub folder. In theory you should be able to patch the sub folder with the parent after the insert but its kind of over kill IMO. Just do it when you insert it.

这篇关于为什么在谷歌驱动器插入文件夹两次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆