我正在尝试从Firebase实时数据库中删除子项以进行C#复制。我在Firebase文档中找不到任何合适的方法。请帮忙。 PS:我刚接触Firebase
答案 0 :(得分:0)
我将向您展示从 FireBaseStorage 数据库中删除数据的 2 种方法,如果您有其他类似从 FireBaseReatimeDatabase 删除的操作,请写信给我,这里是其中 2 种方法: (C# 我使用 FireSharp 和 FireBase 库)
using FireSharp.Config;
using FireSharp.Interfaces;
using FireSharp;
using FirebaseSharp;
using Firebase.Storage;
using FireSharp.EventStreaming;
using FireSharp.Exceptions;
using FireSharp.Response;
using Firebase;
using FirebaseSharp.Portable.Interfaces;
public void DeleteFile(String stream)
{
//Delete file in FireBaseStorage 2 answer
FirebaseStorage storage = new FirebaseStorage("********.appspot.com");
var starsRef = storage.Child(stream);
starsRef.DeleteAsync();
//or
var task = new FirebaseStorage("*******.appspot.com")
.Child(stream)
.DeleteAsync();
}
stream 是文件的路径
答案 1 :(得分:-1)
那么RemoveValueAsync呢?在这里:
DatabaseReference.RemoveValueAsync
就像
DatabaseReference rootReference = FirebaseDatabase.DefaultInstance.RootReference;
DatabaseReference childToRemove = rootReference.Child("your child path");
childToRemove.RemoveValueSync().ContinueWith(
(task) =>
{
if (task.IsCanceled || task.IsFaulted) Debug.Log("Fail");
else if (task.IsCompleted) Debug.Log("Success");
});