dropBoxStorage.GetFolder exception

Mar 23, 2012 at 6:13 PM

Dear All:

I have a problem when I run the program, it will throw a exception when the it run into var publicFolder = dropBoxStorage.GetFolder("/Public"); statement. the following are the code and the exception info. and also there is a yellow question mark on the AppLimit.CloudComputing.SharpBox.Net40 under resource. Please give me some advance. thank you very much.

CloudStorage dropBoxStorage = new CloudStorage();
            var dropBoxConfig = CloudStorage.GetCloudConfigurationEasy(nSupportedCloudConfigurations.DropBox);
            ICloudStorageAccessToken accessToken = null;
            using (FileStream fs = File.Open("DropBoxToken", FileMode.Open, FileAccess.Read, FileShare.None))
            {
                accessToken = dropBoxStorage.DeserializeSecurityToken(fs);
            }
            var storageToken = dropBoxStorage.Open(dropBoxConfig, accessToken);

            // get a specific directory in the cloud storage, e.g. /Public
            var publicFolder = dropBoxStorage.GetFolder("/Public");

 

exception:

AppLimit.CloudComputing.SharpBox.Exceptions.SharpBoxException was unhandled
  HResult=-2146233088
  Message=Couldn't retrieve child elements from the server
  Source=AppLimit.CloudComputing.SharpBox
  StackTrace:
       at AppLimit.CloudComputing.SharpBox.StorageProvider.DropBox.Logic.DropBoxStorageProviderService.RequestResource(IStorageProviderSession session, String Name, ICloudDirectoryEntry parent)
       at AppLimit.CloudComputing.SharpBox.StorageProvider.GenericStorageProvider.GetFileSystemObject(String path, ICloudDirectoryEntry parent)
       at AppLimit.CloudComputing.SharpBox.CloudStorage.GetFileSystemObject(String name, ICloudDirectoryEntry parent)
       at AppLimit.CloudComputing.SharpBox.CloudStorage.GetFolder(String path, ICloudDirectoryEntry parent)
       at AppLimit.CloudComputing.SharpBox.CloudStorage.GetFolder(String path)
       at TutApp01.Program.Main(String[] args) in C:\Users\Simon Fan\Desktop\DropBox\SharpBox-Tut01-App-QuickStartGuide-Code-Version-1-2\TutApp01\TutApp01\Program.cs:line 52
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: System.Web.HttpException
       HResult=-2147467259
       Message=HTTP Error
       ErrorCode=-2147467259
       WebEventCode=0
       InnerException:

Mar 26, 2012 at 12:13 PM

I am recieving this same error.  Any solutions would be a great help!

Coordinator
Mar 26, 2012 at 12:15 PM
Hi,

try to enumerate all childs with a foreach loop starting:

GetRoot
foreach(....)

What happens?

Cheers
Dirk

2012/3/26 LeopoldScotch <notifications@codeplex.com>:
> From: LeopoldScotch
>
> I am recieving this same error.  Any solutions would be a great help!
>
> Read the full discussion online.
>
> To add a post to this discussion, reply to this email
> ([email removed])
>
> To start a new discussion for this project, email
> [email removed]
>
> You are receiving this email because you subscribed to this discussion on
> CodePlex. You can unsubscribe or change your settings on codePlex.com.
>
> Please note: Images and attachments will be removed from emails. Any posts
> to this discussion will also be available online at codeplex.com
Mar 26, 2012 at 1:47 PM
dei79 wrote:
Hi,

try to enumerate all childs with a foreach loop starting:

GetRoot
foreach(....)

What happens?

Cheers
Dirk

When I changed: 
var publicFolder = dropBoxStorage.GetFolder("/Public");

to  

var publicFolder = dropBoxStorage.GetRoot();

The file uploaded successfully. Thanks.

Mar 26, 2012 at 2:12 PM
Edited Mar 26, 2012 at 2:37 PM

Sorry, I just realised that you cannot share files within the apps folder (that GetRoot points to), so therefore the problem is still occurring for me.

 

EDIT: I think the problem is due to permissions when creating you app on dropbox.  When you first create the app, there is the option to grant access to either the "Apps" folder, or the entire users' dropbox.  I was getting the error then I created a new app that requested access to the entire users' dropbox and was then able to get at the public folder.

Mar 26, 2012 at 5:04 PM

Hi dei79:

Thanks first. I try your suggestion as following:

 foreach (var fof in publicFolder)
            {
                string strName = fof.Name;
                Boolean bIsDirectory = fof is ICloudDirectoryEntry;

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

this loop will run only once, the strName is the file's name under App\myCreateApp\ folder. and I still cannot get the folder name.

Mar 28, 2012 at 5:55 PM

any help would be grateful.