Error handling DropNet(dropbox)检查路径,如果为空则创建

Error handling DropNet(dropbox)检查路径,如果为空则创建,error-handling,dropbox-api,dropnet,Error Handling,Dropbox Api,Dropnet,我可以使用dropnet API成功连接到dropbox。我想检查目录(路径)是否存在。一定有比把它当作错误处理更好的方法吗 private void LoadContents() { string _path = null; //_path = "/"; _path = "/PathDoesNotExist"; _client.GetMetaDataAsync(_path, (response) =>

我可以使用dropnet API成功连接到dropbox。我想检查目录(路径)是否存在。一定有比把它当作错误处理更好的方法吗

private void LoadContents()
    {
        string _path = null;
        //_path = "/";
        _path = "/PathDoesNotExist";
        _client.GetMetaDataAsync(_path, (response) =>
        {
            MessageBox.Show(response.Contents.Count(c => c.Is_Dir) + " Folders found.");
        },
        (error) =>
        {
            MessageBox.Show(error.Message);
        });
    }

最好的方法可能是获取父文件夹的元数据并检查其文件夹内容。除此之外,它还将检查异常以获得404的响应。

我必须说,对我来说,查找404似乎比列出整个父目录更有效。(此外,您还必须处理父目录可能不存在的事实。)