-1
這是我第一次做這個項目,我的項目經理讓我有時間研究如何去做。我來自谷歌和一些代碼太複雜了,有沒有一個簡單的方法如何做到這一點?或者我可能不會太複雜。如何使用vb.net將文件上傳到MS一個驅動器?
這是我第一次做這個項目,我的項目經理讓我有時間研究如何去做。我來自谷歌和一些代碼太複雜了,有沒有一個簡單的方法如何做到這一點?或者我可能不會太複雜。如何使用vb.net將文件上傳到MS一個驅動器?
''' <summary>
''' Uploads a file to Microsoft OneDrive.
''' </summary>
''' <param name="FilePath">Path of a file to upload from.</param>
''' <exception cref="KeyNotFoundException">The registry key of MS OneDrive is not found.</exception>
''' <returns>The path of file inside MS OneDrive folder.</returns>
''' <remarks></remarks>
Function UploadToMSOneDrive(FilePath As String) As String
Const keyName As String = "HKEY_CURRENT_USER" & "\\" & "Software\Microsoft\Windows\CurrentVersion\SkyDrive"
Const DefaultKey As String = "OMG Teh ReGiStRy DOesn''''t E.x;I's|T!!!"
Dim OneDrivePath As String = DirectCast(Microsoft.Win32.Registry.GetValue(keyName, "UserFolder", DefaultKey), String)
Dim MSOneDriveProgram As String = IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Microsoft\OneDrive\OneDrive.exe")
Dim Destination As String = IO.Path.Combine(If(OneDrivePath = DefaultKey, OneDrivePath, ThrowKeyNotFoundException("Is MS OneDrive not installed?")), IO.Path.GetFileName(FilePath))
My.Computer.FileSystem.CopyFile(FilePath, Destination)
Process.Start(MSOneDriveProgram)
Return Destination
End Function
Friend Function ThrowKeyNotFoundException(Message As String) As Type
Throw New KeyNotFoundException(Message)
Return GetType(Void) ' This will not be reached
End Function
你試過編碼任何東西嗎?如果是這樣,你可以與我們分享嗎? – ChicagoMike
我沒有,我正在尋找一個簡單的工作代碼使用vb.net可能只是一個單一的按鈕,用戶可以上傳文件到MS一個驅動器。任何幫助將不勝感激謝謝。 – Kiro