Process.Start,如果输入文件== 0 kb则不执行任何操作(Process.Start, do nothing if input file == 0 kb)
我有一个问题,我使用Process.Start来启动可执行文件,虽然可以说:如果input.txt == 0kb什么也不做,否则执行进程?
Process.Start("cmd.exe", @"/c test.exe -f input.txt > output.txt").WaitForExit();
I have a problem, I use Process.Start to launch an executable, although is it possible to say: if input.txt == 0kb do nothing, else execute process ?
Process.Start("cmd.exe", @"/c test.exe -f input.txt > output.txt").WaitForExit();
原文:https://stackoverflow.com/questions/6396661
最满意答案
您可以利用LINQ等C#功能,使其更简单:
table.Source = new TableSource( JsonConvert.DeserializeObject<List<Field>> (response). Select (a => a.Value). ToArray () );
当前代码的问题在于,如果Id不是索引和顺序,则会遇到异常。 如果要对项目进行排序,则可以轻松添加排序:
table.Source = new TableSource( JsonConvert.DeserializeObject<List<Field>> (response). OrderBy(s => s.Id). Select (a => a.Value). ToArray ()
You could take advantage of the C# features like LINQ and make it a much simpler process:
table.Source = new TableSource( JsonConvert.DeserializeObject<List<Field>> (response). Select (a => a.Value). ToArray () );
The problem with your current code is that if the Id's are not 0 indexed and sequential you will run into an exception. If you want to sort the items then you can add sorting easily:
table.Source = new TableSource( JsonConvert.DeserializeObject<List<Field>> (response). OrderBy(s => s.Id). Select (a => a.Value). ToArray ()
相关问答
更多-
该任务是异步的,因此当您加载数组时,您必须重新加载表 func getJSON() { let url = NSURL(string: baseURL) let request = NSURLRequest(URL: url!) let session = NSURLSession(configuration: NSURLSessionConfiguration.defaultSessionConfiguration()) let task = session.dataTa ...
-
看起来像json [“task_name”]不是一个数组而不是第一级,而是task数组中对象的属性,这就是为什么你得到一个空数组。 如果您打算在tableview中显示tak,则应该执行此类操作 if let data = json["tasks"].arrayValue as [JSON]?{ Seems like json["task_name"] is not an array and isn't at first level, instead is a property of the object ...
-
在tableview中填充JSON(populating JSON in tableview)[2023-04-24]
您必须将Company中的employees声明为阵列 var employees = [Employee]() 以及初始化程序 init(name ... , employees: [Employee]) { 并且 - 非常非常重要 -您必须在repeat循环中创建Employee实例,否则您将employees.count乘以相同的对象(由于类的引用语义) ... for employeesDict in employees { if let name = employe ... -
这是因为在viewDidLoad您将numberOfCells设置为> 0但是在eventscd没有任何eventscd 。 这就是为什么当尝试从eventscd读取值时,会得到索引超出范围的错误。 理想情况下,返回的行数应为eventscd.count , eventscd应在加载表内容之前填充eventscd (或者在获取数据并向eventscd添加值后重新加载表) This is because in the viewDidLoad you are setting the numberOfCells ...
-
在视图控制器外部创建一个自定义类Person class Person { var firstName = "" var lastName = "" var title = "" var party = "" } 在视图控制器中创建一个Person数组 var people = [Person]() JSON有一个包含字典数组的关键results 。 在viewDidLoad解析JSON并创建Person实例。 最后重新加载表格视图。 override func viewDidLoad( ...
-
您可以利用LINQ等C#功能,使其更简单: table.Source = new TableSource( JsonConvert.DeserializeObject
- > (response).
Select (a => a.Value).
ToArray ()
);
当前代码的问题在于,如果Id不是索引和顺序,则会遇到异常。 如果要对项目进行排序,则可以轻松添加排序: ...
-
您正在设置数据,如下所示: [_tableData insertObject:title atIndex:0]; [_tableData insertObject:release_year atIndex:1]; [_tableData insertObject:themoviedb atIndex:2]; [_tableData insertObject:original_title atIndex:3]; 但是你正在读出如下数据: ...
-
您可以使用中间自定义结构。 将JSON解析为自定义结构。 使用此结构作为表视图的模型。 当用户点击行映射结构实例到NSManagedObject并保存它。 You could use an intermediate custom struct. Parse the JSON into a custom struct. Use this struct as model for the table view. When the user taps a row map the struct instance to ...
-
尝试使用基于块的NSURLConnection。 我想你形成webdata的方式就是问题。 NSURL *url = [NSURL URLWithString:@"http://url.json"]; NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url]; [NSURLConnection sendAsynchronousRequest:urlRequest queue: ...
-
您没有实例化tableView委托。 确保在viewDidLoad()调用self.weatherTableView.delegate = self 。 此外,每次加载数据时都应创建一个新的arrDict。 self.arrDict = [] 。 如果上述调整不起作用,您应该花些时间调试它。 确保第二个请求正在加载数据,如果是,则可能不会调用self.weatherTableView.reloadData() 。 您可以尝试将其移动到loadDataWeather() 。 You are not insta ...