Forum Discussion

Stevenj519's avatar
Stevenj519
Explorer | Level 3
4 years ago

Moving Local Website and Local SQL to Azure

Hello,

I am in the process of porting my SQL DB and Website to Azure.  Basically, I did it; and it works, EXCEPT, the Dropbox part of it does not work 😞 .  

 

Below is my C# code that works when the website is running on a local machine, it works because the Dropbox app is installed on that Server.  In the below code, Dropbox syncs folders are on the D:\ drive.  It's simple code... if a subfolder doesn't exist, then the code creates a subfolder in Dropbox; then it copies a file to that subfolder.

 

I installed the Dropbox.Api in my Visual Studio web app, but before I start messing things up, I thought I'd ask you smart folks if you can take the below code and tell me what to change it to so it works on Azure App Services.

 

Thank you very much! 

 

string path = formatYYYY + @"\" + formatMM + @"\" + formatDD + @"\";
long s1 = 0;

try
{
if (Directory.Exists(@"D:\Dropbox\Jobisez LLC\Archive\Translation\" + path))
{
}
else
{
DirectoryInfo di = Directory.CreateDirectory(@"D:\Dropbox\Jobisez LLC\Archive\Translation\" + path);
}
}
catch
{
DirectoryInfo di = Directory.CreateDirectory(@"D:\Dropbox\Jobisez LLC\Archive\Translation\" + path);
}

File.Copy(sFileDir + Session.Contents["Id"].ToString() + "." + sFileName + "." + myActivityDtTm + ".TXT", @"D:\Dropbox\Jobisez LLC\Archive\Translation\" + path + Session.Contents["Id"].ToString() + "." + sFileName + "." + myActivityDtTm + ".TXT");

  • kylea's avatar
    kylea
    Icon for Dropbox Staff rankDropbox Staff

    When using the API, you'll need to use the Dropbox methods for browsing the filesystem, getting a path, and downloading it. (The API doesn't mount Dropbox to the local filesystem). See here for the Dropbox .NET SDK overview and here for examples.

     

    • Stevenj519's avatar
      Stevenj519
      Explorer | Level 3

      Hi, and thank you!  But those example are 1000s of lines each.  I'm just trying to find the C# code to create a subfolder within Dropbox (if necessary); and upload a file to that Dropbox subfolder.  Does anyone have the "important" code to do that?  Like the "using" statements, etc.

       

      Thanks again,

      Steve.

      • Greg-DB's avatar
        Greg-DB
        Icon for Dropbox Staff rankDropbox Staff

        Specifically, to create a folder in the connected Dropbox account using the .NET SDK, you'd want to use the CreateFolderV2Async method. And to upload files, you can use the UploadAsync method. Those are links to the documentation for each method for more information on the options offered by each. You can also find the relevant parts of the examples here and here.