Click here to Skip to main content
15,890,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HI all,

i need to upload a file to one drive account to a specific folder using Rest API. i manage to upload a file to one drive but not in a folder which i want to upload. i find on Google but do not find appropriate solution.

below is my code to upload a file to one drive ,

C#
string fileName = string.Empty;
            using (var dlg = new OpenFileDialog())
            {
                dlg.Filter = "All Files|*.*";
                if (dlg.ShowDialog(this) == DialogResult.OK)
                {
                    fileName = dlg.FileName;
                }
            }
            string url = string.Format(@"https://apis.live.net/v5.0/me/skydrive/Files/Isync/{0}?access_token={1}",
                Path.GetFileName(fileName), access_token);
            using (var client = new WebClient())
            {
                client.UploadDataAsync(new Uri(url), "PUT", ImageToByteArray(fileName));
            }
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900