I was having trouble at the start but managed to get scripted files uploading to Dropbox, but it takes so many steps I was hoping someone more experienced can confirm if Im taking the right approach or if there is a simpler way.
Im taking a serialized script, and phrasing it data stream to the UploadAsync() command to be put onto Dropbox.
Also, with the using() eclosed statement on a MemoryStream, do I have to call MemoryStream.Close() at the end? Or does it close itself when the using() statemnt ends?
public async void ResyncCatalogueDatabaseAsync()
{
using (var dbx = new DropboxClient(XXXXXXXXXXX)))
{
BinaryFormatter binaryFormatter = new BinaryFormatter();
using (MemoryStream memoryStream = new MemoryStream())
{
binaryFormatter.Serialize(memoryStream, catalogueDatabase);
using (MemoryStream uploadStream =
new MemoryStream(memoryStream.ToArray()))
{
await dbx.Files.UploadAsync("PATH", WriteMode, body: uploadStream);
Debug.Log("LOG: Catalouge Updated" + DateTime.Now.ToLongDateString());
}
}
}
}
Thank you