internal static void SaveAccessToken() { if (config.DropboxAccessToken != null) { // get the config of dropbox Dropbox.DropBoxConfiguration dropBoxConfig = CloudStorage.GetCloudConfigurationEasy(nSupportedCloudConfigurations.DropBox) as Dropbox.DropBoxConfiguration; CloudStorage storage = new CloudStorage(); // open the connection to the storage storage.Open(dropBoxConfig, config.DropboxAccessToken); Stream tokenStream = storage.SerializeSecurityToken(config.DropboxAccessToken); string fileFullPath = Path.Combine(Environment.CurrentDirectory, Environment.UserName + "-Dropbox.tok"); // Create a FileStream object to write a stream to a file using (FileStream fileStream = System.IO.File.Create(fileFullPath, (int)tokenStream.Length)) { // Fill the bytes[] array with the stream data byte[] bytesInStream = new byte[tokenStream.Length]; tokenStream.Read(bytesInStream, 0, (int)bytesInStream.Length); // Use FileStream object to write to the specified file fileStream.Write(bytesInStream, 0, bytesInStream.Length); } // close the cloud storage connection if (storage.IsOpened) { storage.Close(); } } }