Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get OneDrive path in Windows

I have a C# WPF application and I am trying to find a way to get the path to the root OneDrive directory in Windows. How can I do this programmatically? I have searched online, but I couldn't find anything. I wish I could supply some code but I have no clue; I mean, I have checked system environment variables and I couldn't find anything on my machine, thinking that could be a valid solution, but it didn't turn up anything.

like image 505
Alexandru Avatar asked Nov 06 '14 03:11

Alexandru


Video Answer


2 Answers

With latest update for windows 10, Microsoft introduced new environment variable %OneDrive%, I have checked it on April 2017 update (Creators update) and it is there.

like image 101
mmichtch Avatar answered Sep 17 '22 20:09

mmichtch


This works for me (Windows 10 Pro, 1803):

 var oneDrivePath = Environment.GetEnvironmentVariable("OneDriveConsumer");
like image 20
RexCardan Avatar answered Sep 17 '22 20:09

RexCardan