none
Access/Download File OneDrive using vb.Net, is it possible..? RRS feed

  • Question

  • Dear Friends,

    I have one file (Plain text File) in Microsoft OneDrive Public Folder,

    I want to download or Access that file using VB.NET 2012.

    Is there any way, Please

    Thanks 

    Monday, March 6, 2017 11:20 AM

All replies

  •  OneDrive has an API that i believe they require you to use if you want to interact with their website from your applications.  Do a quick google search for "OneDrive API" and you will see it.


    If you say it can`t be done then i`ll try it

    Monday, March 6, 2017 11:29 AM
  • Most of the examples are going to be in C# using OAuth and REST.

    These links don't show how to but supply information to get started and are in C#.

    https://dev.onedrive.com/README.htm
    https://github.com/OneDrive/onedrive-sample-apibrowser-dotnet
    https://dev.onedrive.com/misc/verb-tunneling.htm


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Monday, March 6, 2017 11:56 AM
    Moderator
  • Do I miss something in this question?

    Public Class Form1
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            TextBox1.Text = IO.File.ReadAllText("C:\Users\Cor\SkyDrive\Documenten\MyNote.txt")
        End Sub
    
        Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
            IO.File.WriteAllText("C:\Users\Cor\SkyDrive\Documenten\MyNote.txt", TextBox1.Text)
        End Sub
    End Class


    Success
    Cor

    Monday, March 6, 2017 4:44 PM
  • Do I miss something in this question?

    Public Class Form1
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            TextBox1.Text = IO.File.ReadAllText("C:\Users\Cor\SkyDrive\Documenten\MyNote.txt")
        End Sub
    
        Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
            IO.File.WriteAllText("C:\Users\Cor\SkyDrive\Documenten\MyNote.txt", TextBox1.Text)
        End Sub
    End Class


    Success
    Cor


     Yes,  i think you missed the part where OP says they want to access or download the file from a public folder on OneDrive.  8)

    If you say it can`t be done then i`ll try it

    Tuesday, March 7, 2017 1:06 AM
  • Yes,  i think you missed the part where OP says they want to access or download the file from a public folder on OneDrive.  8)

    I think the point is that if OneDrive is configured correctly then the cloud storage is accessed as if it is a local folder. No special code is needed.   PerhapsSkyDrive is the name that was used previously, but the local OneDrive folder could actually be named anything at all.

    Tuesday, March 7, 2017 2:34 AM
  • It is month I was working on this problem. Apparently the solution is very simple. No special code is needed.

    Dim textOnFile_0 = IO.File.ReadAllText("C:\Users\UserName\OneDrive\TestFile.txt")

    Too easy?

    Of course I'll use

    Try

      ...

    In order to catch errors

    What I've to do in order to read data of someone else OneDrive?

    I've tried also:

    Dim textOnFile_1 = IO.File.ReadAllText("C:\Users\UserName\Google Drive\TestFile.txt")

    Pay attention to write the space inside the word Google Drive

    In order to share Google Drive with someone else apparently the solution is easy but not yet tried

    Tuesday, March 21, 2017 9:17 AM
  • It is month I was working on this problem. Apparently the solution is very simple. No special code is needed.

    Dim textOnFile_0 = IO.File.ReadAllText("C:\Users\UserName\OneDrive\TestFile.txt")

    Too easy?

    Of course I'll use

    Try

      ...

    In order to catch errors

    What I've to do in order to read data of someone else OneDrive?

    I've tried also:

    Dim textOnFile_1 = IO.File.ReadAllText("C:\Users\UserName\Google Drive\TestFile.txt")

    Pay attention to write the space inside the word Google Drive

    In order to share Google Drive with someone else apparently the solution is easy but not yet tried

    Yes that I wrote 15 days ago in this thread, but some wanted it more difficult. 

    Success
    Cor


    Tuesday, March 21, 2017 11:08 AM
  • Sorry .. forgot.

    Many thanks Cor

    Tuesday, March 21, 2017 11:23 AM
  • Sorry .. forgot.

    If one or more of the responses assisted you in finding the solution then they should be marked as the answer, so that others with a similar question know which comments they should take note of.

    Tuesday, March 21, 2017 8:53 PM
  • Yes that I wrote 15 days ago in this thread, but some wanted it more difficult. 

    Success
    Cor


     I have never saw nor heard of setting One Drive up to access like you showed.  I was in no way trying to make anything more difficult as you say i intended to do.

    If you say it can`t be done then i`ll try it

    • Edited by IronRazerz Tuesday, March 21, 2017 9:37 PM
    Tuesday, March 21, 2017 9:37 PM
  • Yes that I wrote 15 days ago in this thread, but some wanted it more difficult. 

    Success
    Cor


     I have never saw nor heard of setting One Drive up to access like you showed.  I was in no way trying to make anything more difficult as you say i intended to do.

    If you say it can`t be done then i`ll try it

    ... Hi,

    if you dont use the OneDrive App on your computer you wont have such a local copy of the online state, so most of the Win7 users will *have to use* the OneDrive api... so there's nothing that you made more difficult than needed IMHO. But if you use the App plus correct settings, then the way Cor shows is the simplest possible IMHO.

    Regards,

      Thorsten

    Wednesday, March 22, 2017 9:59 AM
  • I too am working on a project that moves files from the end users local system to a onedrive folder. I am a novice, okay very novice, programmer who writes in VB. I want my app to be able to used by other people who may not have access to the onedrive folder directly, so they wont have a local drive or folder that syncs with onedrive. I want my app to login to onedrive and copy files.

    My point is this. The question in the beginning of this thread was:

    "I have one file (Plain text File) in Microsoft OneDrive Public Folder,

    I want to download or Access that file using VB.NET 2012.

    Is there any way, Please"

    It seems to me that there are more responses to this thread that seem to find ways NOT to do what is proposed by suggesting that there is a way around it by using the local sync'd folder. But what if he is not the only one using his app? What if he doesn't want those that use the app to have direct access to the onedrive folder?

    I enjoyed Karen's response and will research that until I come up with a way to accomplish this. If I do, I will post the results here.

    Saturday, July 29, 2017 12:46 PM
  • It seems to me that there are more responses to this thread that seem to find ways NOT to do what is proposed by suggesting that there is a way around it by using the local sync'd folder. But what if he is not the only one using his app? What if he doesn't want those that use the app to have direct access to the onedrive folder?

    The 'local sync'd folder' and the 'Microsoft OneDrive Public Folder' are the same folder. The OP is not accessing that file on the remote server.  OP didn't mention restricting access to the local folder.

    If you want to do research about accessing OneDrive files direct from the remote server then that may be worthwhile, but it's not a discussion for this thread. Start a new thread with a title that describes that task.

    Saturday, July 29, 2017 9:38 PM
  • LOL! I Love your tagline.  That's how I became an "expert" with the Windows Registry.  Back in '98 a coworker told me, "OH, never touch the registry.".

    Helpful nice guy

    Saturday, January 12, 2019 8:25 AM
  • I hope you modified your code since then.  You shouldn't use "Static" addresses.  I've encountered a lot of companies that use different drives like D: or U: for User Profiles.

    Dim strUserProfile As String = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)

    Dim textOnFile_0 = IO.File.ReadAllText(strUserProfile & "\OneDrive\TestFile.txt")

    You might not need the As String part but I can't say 100% for sure or not.  I know it will work without it but a friend told me I should always try to declare the variable type. 


    Helpful nice guy

    Saturday, January 12, 2019 7:09 PM