C# 给定路径';读取Json文件时不支持s格式

C# 给定路径';读取Json文件时不支持s格式,c#,json,wpf,C#,Json,Wpf,我正在尝试读取Json文件并将其反序列化。但当我试图读取文件时,它会说“不支持给定路径的格式”。这是我的json文件。在发帖之前,我浏览了这篇文章,但我想这与我的问题无关 在这里编辑我的文章是这个项目的结构。主解决方案->视图模型(文件夹)->DGXRun.json { "type": "DGX parameter file", "version": "v1.0", "date": "01/10/2018", "assays": [ {

我正在尝试读取Json文件并将其反序列化。但当我试图读取文件时,它会说“不支持给定路径的格式”。这是我的json文件。在发帖之前,我浏览了这篇文章,但我想这与我的问题无关

在这里编辑我的文章是这个项目的结构。主解决方案->视图模型(文件夹)->DGXRun.json

{
    "type": "DGX parameter file",
    "version": "v1.0",
    "date": "01/10/2018",

    "assays": [
        {
            "assay_1": {
                "display_name": "W3 single cell V1.0",
                "volumes": [
                    {
                        "volume_1": {
                            "volume_display_value": 20,
                            "global_parameters": {
                                "param1": 5
                            },
                            "run": {
                                "Initialize coarse reservoirs": {
                                    "Max time": 30.0,
                                    "Min time": 5.0,
                                    "Set temperature": 22.0,
                                    "Air flow min": 0,
                                    "Air flow max": 0,
                                    "Vacuum Reservoir Pressure": -5.0,
                                    "Pressure Reservoir Pressure": 5.0,
                                    "Channel 1 Pressure": 0.0,
                                    "Channel 2 Pressure": 0.0,
                                    "Channel 3 Pressure": 0.0,
                                    "Channel 4 Pressure": -1.75,
                                    "V13:Channel 1OutletValve": "Closed",
                                    "V14:Channel 2OutletValve": "Closed",
                                    "V15:Channel 3 Outlet Valve": "Closed",
                                    "V16:Channel 4 Outlet Valve": "Closed",
                                    "V17:Channel 1 Small Large Valve": "Small",
                                    "V18:Channel 2 Small Large Valve": "Small",
                                    "V19:Channel 3 Small Large Valve": "Small"
                                },
                                "Create droplets": {
                                    "Max time": 180.0,
                                    "Min time": 180.0,
                                    "Set temperature": 22.0,
                                    "Air flow min": 0,
                                    "Air flow max": 2,
                                    "Vacuum Reservoir Pressure": -5.0,
                                    "Pressure Reservoir Pressure": 5.0,
                                    "Channel 1 Pressure": 0.0,
                                    "Channel 2 Pressure": 0.0,
                                    "Channel 3 Pressure": 0.0,
                                    "Channel 4 Pressure": -1.75,
                                    "V13: Channel 1 Outlet Valve": "Closed",
                                    "V14: Channel 2 Outlet Valve": "Closed",
                                    "V15: Channel 3 Outlet Valve": "Closed",
                                    "V16: Channel 4 Outlet Valve": "Open",
                                    "V17: Channel 1 Small Large Valve": "Small",
                                    "V18: Channel 2 Small Large Valve": "Small",
                                    "V19: Channel 3 Small Large Valve": "Small"
                                },
                                "Initialize Pushback": {
                                    "Max time": 5.0,
                                    "Min time": 1.0,
                                    "Set temperature": 22.0,
                                    "Air flow min": 0,
                                    "Air flow max": 0,
                                    "Vacuum Reservoir Pressure": -5.0,
                                    "Pressure Reservoir Pressure": 5.0,
                                    "Channel 1 Pressure": 0.0,
                                    "Channel 2 Pressure": 0.0,
                                    "Channel 3 Pressure": 0.0,
                                    "Channel 4 Pressure": 2.0,
                                    "V13: Channel 1 Outlet Valve": "Closed",
                                    "V14: Channel 2 Outlet Valve": "Closed",
                                    "V15: Channel 3 Outlet Valve": "Closed",
                                    "V16: Channel 4 Outlet Valve": "Closed",
                                    "V17: Channel 1 Small Large Valve": "Small",
                                    "V18: Channel 2 Small Large Valve": "Small",
                                    "V19: Channel 3 Small Large Valve": "Small"
                                },
                                "Pushback": {
                                    "Max time": 25.0,
                                    "Min time": 25.0,
                                    "Set temperature": 22.0,
                                    "Air flow min": 0,
                                    "Air flow max": 0,
                                    "Vacuum Reservoir Pressure": -5.0,
                                    "Pressure Reservoir Pressure": 5.0,
                                    "Channel 1 Pressure": 0.0,
                                    "Channel 2 Pressure": 0.0,
                                    "Channel 3 Pressure": 0.0,
                                    "Channel 4 Pressure": 2.0,
                                    "V13: Channel 1 Outlet Valve": "Closed",
                                    "V14: Channel 2 Outlet Valve": "Closed",
                                    "V15: Channel 3 Outlet Valve": "Closed",
                                    "V16: Channel 4 Outlet Valve": "Open",
                                    "V17: Channel 1 Small Large Valve": "Small",
                                    "V18: Channel 2 Small Large Valve": "Small",
                                    "V19: Channel 3 Small Large Valve": "Small"
                                },
                                "End": {
                                    "Max time": 5.0,
                                    "Min time": 1.0,
                                    "Set temperature": 22.0,
                                    "Air flow min": 0,
                                    "Air flow max": 0,
                                    "Vacuum Reservoir Pressure": 0.0,
                                    "Pressure Reservoir Pressure": 0.0,
                                    "Channel 1 Pressure": 0.0,
                                    "Channel 2 Pressure": 0.0,
                                    "Channel 3 Pressure": 0.0,
                                    "Channel 4 Pressure": 0.0,
                                    "V13: Channel 1 Outlet Valve": "Closed",
                                    "V14: Channel 2 Outlet Valve": "Closed",
                                    "V15: Channel 3 Outlet Valve": "Closed",
                                    "V16: Channel 4 Outlet Valve": "Closed",
                                    "V17: Channel 1 Small Large Valve": "Small",
                                    "V18: Channel 2 Small Large Valve": "Small",
                                    "V19: Channel 3 Small Large Valve": "Small"
                                }
                            }
                        },
                        "volume_2": {
                            "volume_display_value": 50,
                            "global_parameters": {
                                "param1": 5
                            },
                            "run": {
                                "Step 1": {
                                    "Max time": 30.0,
                                    "Min time": 5.0,
                                    "Set temperature": 22.0,
                                    "Air flow min": 0,
                                    "Air flow max": 0,
                                    "Vacuum Reservoir Pressure": -5.0,
                                    "Pressure Reservoir Pressure": 5.0,
                                    "Channel 1 Pressure": 0.0,
                                    "Channel 2 Pressure": 0.0,
                                    "Channel 3 Pressure": 0.0,
                                    "Channel 4 Pressure": -1.75,
                                    "V13: Channel 1 Outlet Valve": "Closed",
                                    "V14: Channel 2 Outlet Valve": "Closed",
                                    "V15: Channel 3 Outlet Valve": "Closed",
                                    "V16: Channel 4 Outlet Valve": "Closed",
                                    "V17: Channel 1 Small Large Valve": "Small",
                                    "V18: Channel 2 Small Large Valve": "Small",
                                    "V19: Channel 3 Small Large Valve": "Small"
                                },
                                "Step 2": {
                                    "Max time": 180.0,
                                    "Min time": 180.0,
                                    "Set temperature": 22.0,
                                    "Air flow min": 0,
                                    "Air flow max": 2,
                                    "Vacuum Reservoir Pressure": -5.0,
                                    "Pressure Reservoir Pressure": 5.0,
                                    "Channel 1 Pressure": 0.0,
                                    "Channel 2 Pressure": 0.0,
                                    "Channel 3 Pressure": 0.0,
                                    "Channel 4 Pressure": -1.75,
                                    "V13: Channel 1 Outlet Valve": "Closed",
                                    "V14: Channel 2 Outlet Valve": "Closed",
                                    "V15: Channel 3 Outlet Valve": "Closed",
                                    "V16: Channel 4 Outlet Valve": "Open",
                                    "V17: Channel 1 Small Large Valve": "Small",
                                    "V18: Channel 2 Small Large Valve": "Small",
                                    "V19: Channel 3 Small Large Valve": "Small"
                                },
                                "Step 3": {
                                    "Max time": 5.0,
                                    "Min time": 1.0,
                                    "Set temperature": 22.0,
                                    "Air flow min": 0,
                                    "Air flow max": 0,
                                    "Vacuum Reservoir Pressure": -5.0,
                                    "Pressure Reservoir Pressure": 5.0,
                                    "Channel 1 Pressure": 0.0,
                                    "Channel 2 Pressure": 0.0,
                                    "Channel 3 Pressure": 0.0,
                                    "Channel 4 Pressure": 2.0,
                                    "V13: Channel 1 Outlet Valve": "Closed",
                                    "V14: Channel 2 Outlet Valve": "Closed",
                                    "V15: Channel 3 Outlet Valve": "Closed",
                                    "V16: Channel 4 Outlet Valve": "Closed",
                                    "V17: Channel 1 Small Large Valve": "Small",
                                    "V18: Channel 2 Small Large Valve": "Small",
                                    "V19: Channel 3 Small Large Valve": "Small"
                                },
                                "Step 4": {
                                    "Max time": 25.0,
                                    "Min time": 25.0,
                                    "Set temperature": 22.0,
                                    "Air flow min": 0,
                                    "Air flow max": 0,
                                    "Vacuum Reservoir Pressure": -5.0,
                                    "Pressure Reservoir Pressure": 5.0,
                                    "Channel 1 Pressure": 0.0,
                                    "Channel 2 Pressure": 0.0,
                                    "Channel 3 Pressure": 0.0,
                                    "Channel 4 Pressure": 2.0,
                                    "V13: Channel 1 Outlet Valve": "Closed",
                                    "V14: Channel 2 Outlet Valve": "Closed",
                                    "V15: Channel 3 Outlet Valve": "Closed",
                                    "V16: Channel 4 Outlet Valve": "Open",
                                    "V17: Channel 1 Small Large Valve": "Small",
                                    "V18: Channel 2 Small Large Valve": "Small",
                                    "V19: Channel 3 Small Large Valve": "Small"
                                },
                                "Step 5": {
                                    "Max time": 5.0,
                                    "Min time": 1.0,
                                    "Set temperature": 22.0,
                                    "Air flow min": 0,
                                    "Air flow max": 0,
                                    "Vacuum Reservoir Pressure": 0.0,
                                    "Pressure Reservoir Pressure": 0.0,
                                    "Channel 1 Pressure": 0.0,
                                    "Channel 2 Pressure": 0.0,
                                    "Channel 3 Pressure": 0.0,
                                    "Channel 4 Pressure": 0.0,
                                    "V13: Channel 1 Outlet Valve": "Closed",
                                    "V14: Channel 2 Outlet Valve": "Closed",
                                    "V15: Channel 3 Outlet Valve": "Closed",
                                    "V16: Channel 4 Outlet Valve": "Closed",
                                    "V17: Channel 1 Small Large Valve": "Small",
                                    "V18: Channel 2 Small Large Valve": "Small",
                                    "V19: Channel 3 Small Large Valve": "Small"
                                }
                            }
                        }

                    }
                ]
            },

            "assay_2": {
                "display_name": "W3 single cell V2.0",
                "volumes": [
                    {
                        "volume_1": {
                            "volume display value": 100,
                            "global parameters": {
                                "param1": 0
                            },
                            "run": {
                            }
                        }

                    }
                ]
            }
        }
    ]
}
我就是这样读的

string json = File.ReadAllText("pack://application:,,,/BioRad.NextGenDG.ViewModels;component/DGXRun.json"); //I get an exception here.
            var data = JsonConvert.DeserializeObject<ReadJsonAssays>(json);
string json=File.ReadAllText(“pack://application:,,,/BioRad.NextGenDG.ViewModels;component/DGXRun.json”)//我这里有个例外。
var data=JsonConvert.DeserializeObject(json);

我认为
File.ReadAllText
仅用于文件系统路径。我不认识这个“pack://...“等等。路径,我猜这就是
File.ReadAllText
被阻塞的地方。如果您可以以其他方式读取该文件的内容(例如,使用
WebClient
?),那么您应该能够将内容传递到
反序列化对象中

错误消息与JSON文件无关。