Forum Discussion

sasthamanik's avatar
sasthamanik
Copper Contributor
Dec 16, 2020

One Drive Local Machine configuration Path

HI All,

 

I'm trying to get Microsoft OneDrive configured path (folder path) in local machine with help of C#. Is there any solution available to get the Local configured folder path, below are my script but its throwing error. Please help on this ..

 

try
        {
             const string userRoot = "HKEY_CURRENT_USER";
             const string subkey = @"Software\Microsoft\OneDrive";
             const string keyName = userRoot + "\\" + subkey;
             string oneDrivePath = (string)Microsoft.Win32.Registry.GetValue(keyName,
                "UserFolder",
               "Return this default if NoSuchName does not exist.");
             Console.WriteLine("\r\n OneDrivePath : {0}", oneDrivePath);
            string Onedrivepath= string.Format(oneDrivePath);
             label1 .Text = string.Format(Onedrivepath);
        }
        catch (Exception)
        {
            /// throw;
        }

 

 

Resources