DriveClientUpdateFile(FileInfo, File) Method
Updates (replaces) a existing file in the specified folder.
Namespace: DevCase.ThirdParty.Google.DriveAssembly: DevCase.net48.ThirdParty.GoogleServices (in DevCase.net48.ThirdParty.GoogleServices.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
public KeyValuePair<ResumableUpload, File> UpdateFile(
FileInfo srcFile,
File dstFile
)
Public Function UpdateFile (
srcFile As FileInfo,
dstFile As File
) As KeyValuePair(Of ResumableUpload, File)
Dim instance As DriveClient
Dim srcFile As FileInfo
Dim dstFile As File
Dim returnValue As KeyValuePair(Of ResumableUpload, File)
returnValue = instance.UpdateFile(srcFile,
dstFile)
public:
KeyValuePair<ResumableUpload^, File^> UpdateFile(
FileInfo^ srcFile,
File^ dstFile
)
member UpdateFile :
srcFile : FileInfo *
dstFile : File -> KeyValuePair<ResumableUpload, File>
No code example is currently available or this language may not be supported.
- srcFile FileInfo
-
The source file to upload.
- dstFile File
-
The metadata of the existing file being updated.
KeyValuePairResumableUpload,
File
The resulting
KeyValuePairTKey, TValue.
This is a code example.
No code example is currently available or this language may not be supported.
Private Sub UpdateFile()
Dim client As New DriveClient("C:\GoogleSecrets.json", "yourmail@gmail.com", DriveScopes.Full)
Dim credential As UserCredential = client.Authorize()
Dim srcFile As New FileInfo("C:\File.ext")
Dim dstFile As Google.Apis.Drive.v3.Data.File = client.GetFilesByName("File to update.ext").Single()
Dim result As KeyValuePair(Of Google.Apis.Upload.ResumableUpload, Google.Apis.Drive.v3.Data.File) =
client.UpdateFile(srcFile, dstFile)
Dim upload As Global.Google.Apis.Upload.ResumableUpload = result.Key
Select Case upload.GetProgress().Status
Case Global.Google.Apis.Upload.UploadStatus.Failed
Console.WriteLine("Upload Failed.")
' To-Do: Retry/Resume Upload?:
' upload.Upload()
' upload.Resume()
Case Global.Google.Apis.Upload.UploadStatus.Completed
Dim dstFile As Global.Google.Apis.Upload.ResumableUpload = result.Value
Dim sb As New Global.System.Text.StringBuilder()
With sb
.AppendLine(String.Format("Id: {0}", dstFile.Id))
.AppendLine(String.Format("Name: {0}", dstFile.Name))
.AppendLine(String.Format("Size: {0}", dstFile.Size))
.AppendLine(String.Format("MIME type: {0}", dstFile.MimeType))
.AppendLine(String.Format("Date Created: {0}", dstFile.CreatedTime?.ToString()))
.AppendLine(String.Format("Url: {0}", If(dstFile.WebContentLink, dstFile.WebViewLink)))
.AppendLine(String.Format("Parent Folder Ids: {0}", String.Join(",", If(dstFile.Parents, {"nul"}))))
End With
Console.WriteLine(sb.ToString())
End Select
End Sub
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.