I'm back again!
public class Program
{
public Logger logger;
public string localFilePath = @C:\Users\hbuuutaag\Documents\Code Tests\Test;
public static void Main(string[] args)
{
Program program = new Program();
var task = Task.Run((Func<Task>)program.Run);
task.Wait();
}
public async Task Run()
{
using (var dbx = new DropboxClient("API TOKEN"))
{
logger = NLog.LogManager.GetLogger("logger");
var full = await dbx.Users.GetCurrentAccountAsync();
logger.Info("{0} - {1}", full.Name.DisplayName, full.Email);
var listOfFolders = await dbx.Files.ListFolderAsync(string.Empty, true);
FolderMetadata dropboxFolderInfo = new FolderMetadata();
FileMetadata dropboxFileInfo = new FileMetadata();
foreach (var item in listOfFolders.Entries)
{
try
{
if (item.IsFile)
{
dropboxFileInfo = (FileMetadata)item;
logger.Info("Processing " + dropboxFileInfo.PathLower.ToString());
using (var response = await dbx.Files.DownloadAsync(dropboxFileInfo.PathLower.ToString()))
{
using (FileStream fileStream = File.Create(localFilePath))
{
(await response.GetContentAsStreamAsync()).CopyTo(fileStream);
logger.Info("Downloaded " + dropboxFileInfo.PathLower.ToString() + " successfully");
}
}
}
}
catch (Exception ex)
{
logger.Error(ex.ToString() + "\t" + dropboxFileInfo);
}
}
I'm iterating through the list of folders successfully, but when I try to pass the file name in to the download handler it's downloading one document with Wingdings galore! Probably missing something super basic...
Thanks in advance!