Error 401

May 29, 2015 at 10:34 AM
Edited May 29, 2015 at 10:58 AM
Hi, I'm getting error 401 when I'm trying to upload a file, I can read the list of files just fine from my dropbox but when I use dropbox.uploadfile I get the error 401, anyone has any idea what could be wrong?

CloudStorage DropBox = new CloudStorage();
        var dropBoxConfig = CloudStorage.GetCloudConfigurationEasy(nSupportedCloudConfigurations.DropBox);
        ICloudStorageAccessToken accessToken = null;


        using (FileStream fs = File.Open(@"C:\projects\Dropbox Upload Test\uploadtestdrop\uploadtestdrop\SharpDropBox.Token", FileMode.Open, FileAccess.Read, FileShare.None))
        {
            accessToken = DropBox.DeserializeSecurityToken(fs);
        }


        var storagetok = DropBox.Open(dropBoxConfig, accessToken);



        var publicFolder = DropBox.GetFolder("/Test");
        foreach (var fof in publicFolder)
        {
            Boolean bIsDirectory = fof is ICloudDirectoryEntry;

            Console.WriteLine("{0}: {1}", bIsDirectory ? "DIR" : "FIL", fof.Name);
        }
        string path = @"C:\testup";
       DirectoryInfo d = new DirectoryInfo(path);
        try
        {


            DropBox.UploadFile(@"C:\\testup\\test1.txt", publicFolder);
        }
        catch (Exception ex)
        {
            Console.WriteLine("Error!");
            string filepath = @"C:\testup\Error.txt";
            using (StreamWriter writer = new StreamWriter(filepath, true))
            {
                writer.WriteLine("Message :" + ex.Message + Environment.NewLine + ex);

            }
        }
        foreach (var file in d.GetFiles("*.*"))
        {
            string srcFile = Environment.ExpandEnvironmentVariables(file.FullName);
            DropBox.UploadFile(srcFile, publicFolder);
        }

        foreach (var fof in publicFolder)
        {
            Boolean bIsDirectory  = fof is ICloudDirectoryEntry;

            Console.WriteLine("{0}: {1}", bIsDirectory ? "DIR" : "FIL", fof.Name);
        }

        DropBox.Close();
        Console.ReadKey();



EDIT: I found the problem so nvm, I could upload to root just not a folder.