我在vb.net中有一个项目,第一步是选择硬盘中存在的目录,并列出.learnMore {
width:140px;
height:35px;
border:1px solid purple;
margin:0 auto;
&:hover {
background-color:purple;
}
&:hover > h3 {
color: #fff;
}
}
中此目录中存在的所有文件。
在所选目录和在Google云端硬盘中选择的文件夹之间比较第二个。
当我发现硬盘驱动器上存在文件而不是驱动器中的文件时,我将其列在gridview
中并将其上传到驱动器中
我的问题是上传到驱动器,例外是:
listviewitem
这意味着访问路径' D:\ *****'被拒绝
这是我的代码,这是按钮上传到驱动器事件:
System.UnauthorizedAccessException : "L'accès au chemin d'accès 'D:\*****' est refusé."
Dim ligne As Integer = fs.Items.Count
Dim i As Integer
Dim val As String
For i = 0 To ligne - 1
val = folder_hard.Item(0, i).Value
Form1.insert(folder.Text, valeur)
Next
用于计算网格中的数字行
ligne
用于val
中所选行的索引
listview
是一种上传文件方法
上传文件方法代码:
insert
此行发生异常:
Public Sub insert(nom_dossier As String, nom_fichier As String)
CreateService()
Dim f As New Google.Apis.Drive.v2.Data.File()
f.Title = nom_fichier
Dim reference As New ParentReference()
f.Parents = New List(Of ParentReference)
reference.Id = exist(nom_dossier)'test if folder exist or not
f.Parents.Add(reference)
f.MimeType = "text/plain , Image / jpeg"
' lire le fichier dans un tableau d'octet
Dim chemin As String = System.IO.Path.Combine("D:\*****")
Dim byteArray As Byte() = System.IO.File.ReadAllBytes(chemin)
Dim stream As New System.IO.MemoryStream()
Dim res = Service.Files.Insert(f, stream, f.MimeType).Upload
MessageBox.Show("Succés d'upload")
End sub