This project is read-only.
1
Vote

"Couldn't retrieve child elements from the server" on cloudstorage.getfolder("/"+path1)

description

I am using sharpbox to connect with DropBox and able to retrieve some directories but I am not able to retrieve the child directories and their file, I don't know where where I was made mistake. anyone one having idea about this please let me know.

Following is my code
  //Getting token details from database and  convert string to stream 
                byte[] byteArray = Encoding.UTF8.GetBytes(tokentbl.AsEnumerable().Select(x => x["AccessToken"].ToString()).FirstOrDefault());
                //byte[] byteArray = Encoding.ASCII.GetBytes(contents);
                MemoryStream stream = new MemoryStream(byteArray);

                CloudStorage storageNew = new CloudStorage();
                accessToken = storageNew.DeserializeSecurityToken(stream);
                //storageNew.Open(config, accessToken);

                //var path1 = path.Substring(0, path.LastIndexOf('/'));
                //var publicFolder1 = storageNew.GetRoot();
                storageNew.Open(config, accessToken);
                var path1 = path.Substring(0, path.LastIndexOf('/'));
                var publicFolder1 = storageNew.GetFolder("/" + path1);//path1 is parent child folder path
                var pathh = (from t in publicFolder1 where t != null && t.Name.ToString() == path.Split('/').Last() select t).First();

                Boolean bIsDirectory1 = pathh is ICloudDirectoryEntry;

                //foreach (var item in publicFolder1.ToList())
                //{
                //    Boolean bIssDirectory1 = item is ICloudDirectoryEntry;
                //if (bIsDirectory1)
                //{
                if (!bIsDirectory1)
                {
                    storageNew.DownloadFile(path, @"D:\Files\");
                }
                else
                {
                    string Folder = ""; string file = "";
                    // 6. Try to do something
                    var publicFolder = storageNew.GetFolder("/" + path);//getting error here 
                    foreach (var fof in publicFolder)
                    {
                        // check if we have a directory 
                        Boolean bIsDirectory = fof is ICloudDirectoryEntry;
                        if (bIsDirectory)
                        {
                            Folder += ",\"" + fof.Name + "\"";

                        }
                        else if (!bIsDirectory)
                        {
                            file += ",\"" + fof.Name + "\"";
                        }
                    }
                    Folder = Folder.Length > 0 ? Folder.Remove(0, 1) : Folder;
                    file = file.Length > 0 ? file.Remove(0, 1) : file;
                    string jsonstring = "{\"folder\":" + "[" + Folder + "],\"file\":" + "[" + file + "],\"path\":[\"" + path + "\"]}";
                    Clients.Client(ClientID).showDirectory(jsonstring);//passing list to client side using signalR

comments