directory.getfiles在出错时停止搜索(directory.getfiles stops searching when error)
我有这个代码巫婆完全适用于我的开发环境:
String[] FileNames = Directory.GetFiles(path, "*.*", SearchOption.AllDirectories).Where(s => s.EndsWith(".bak") || s.EndsWith(".dwg")).ToArray(); var queryDupNames = from f in FileNames group f by Path.GetFileNameWithoutExtension(f) into g where g.Count() > 1 select new { Name = g.Key, FileNames = g } ; var lista = queryDupNames.ToList();
使用此代码,我查找具有相同名称和不同扩展名(bak和dwg)的文件。 当我用我的公司映射驱动器尝试这个时,我收到了这个错误:
Excepción no controlada: System.IO.DirectoryNotFoundException: No se puede encontrar una parte de la ruta de acceso 'O:\auskalononden\sistema de gestion\mantenimiento\01.-Maquinas y utiles\COMPROBADORAS\utiles y maquinas sin presion ni agua original\Deapnelizadora de alimantacion CODIGO-- ESPAÑA-- FRANCIA\JAULA GIRONA ESPAÑA FRANCIA\Jaula de utensilios KIDJQd sC-22\4403.-repu'. en System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) en System.IO.Directory.InternalGetFileDirectoryNames(String path, String userPathOriginal, String searchPattern, Boolean includeFiles, Boolean includeDirs, SearchOption searchOption) en System.IO.Directory.GetFiles(String path, String searchPattern, SearchOption searchOption) en bakdwg.Program.Main(String[] args) en D:\dev\bakdwg\bakdwg\Program.cs:línea 19
有没有什么可说的:如果你对这条路径有错误,请按照下一条路径进行操作? 或者其他的东西?
I have this code witch works perfectly on my dev enviroment:
String[] FileNames = Directory.GetFiles(path, "*.*", SearchOption.AllDirectories).Where(s => s.EndsWith(".bak") || s.EndsWith(".dwg")).ToArray(); var queryDupNames = from f in FileNames group f by Path.GetFileNameWithoutExtension(f) into g where g.Count() > 1 select new { Name = g.Key, FileNames = g } ; var lista = queryDupNames.ToList();
With this code I´m looking for files with the same name and different extension (bak and dwg). When I tried this with my company mapped drive I got this error:
Excepción no controlada: System.IO.DirectoryNotFoundException: No se puede encontrar una parte de la ruta de acceso 'O:\auskalononden\sistema de gestion\mantenimiento\01.-Maquinas y utiles\COMPROBADORAS\utiles y maquinas sin presion ni agua original\Deapnelizadora de alimantacion CODIGO-- ESPAÑA-- FRANCIA\JAULA GIRONA ESPAÑA FRANCIA\Jaula de utensilios KIDJQd sC-22\4403.-repu'. en System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) en System.IO.Directory.InternalGetFileDirectoryNames(String path, String userPathOriginal, String searchPattern, Boolean includeFiles, Boolean includeDirs, SearchOption searchOption) en System.IO.Directory.GetFiles(String path, String searchPattern, SearchOption searchOption) en bakdwg.Program.Main(String[] args) en D:\dev\bakdwg\bakdwg\Program.cs:línea 19
Is there any whay to tell: if you have an error with this path, follow with next path? or something?
原文:
更新时间:2022-01-14 22:01
最满意答案
直接JavaScript代码(无库)的答案:
var result = {}; for (var i = 0; i < people.length; i++) { var item = people[i]; for (var key in item) { if (!(key in result)) result[key] = []; result[key].push(item[key]); } }
An answer in straightforward JavaScript code (no libraries):
var result = {}; for (var i = 0; i < people.length; i++) { var item = people[i]; for (var key in item) { if (!(key in result)) result[key] = []; result[key].push(item[key]); } }
相关问答
更多-
数组的对象键(Object Keys to Array)[2023-10-27]
你需要将你的return移到你的循环之外: function getAllKeys(object){ var array = []; for(var key in object){ array.push(key); } return array; } var myObj = { name:"bellamy", age:25 }; getAllKeys(myObj); 这是因为你的函数会在第一次遇到return时立 ... -
第一种方法是将中间数组映射到对象数组 const xData = [1, 3, 5, 7, 9]; const yData = [2, 4, 6, 8, 10]; var coords = xData.map((v, i) => [v, yData[i]]).map(([x, y]) => ({x, y})); console.log(coords); 作为奖励,请参阅当前地图回调的简写 第二个(首选,除非你也想要数组版本)方法是直接映射到一个对象 const xData = [1, 3, 5 ...
-
在Javascript中,一个数组只能被一个数字索引(它不像PHP)。 这就是说,你可以在对象(json)中拥有两个值,就像你想要的那样。 所以,你会有这样的东西: const mediaContent = { link1: content1, link2: content2, link3: content3 } 然后,你只需要像数组一样对待你的对象。 一个对象没有方法pop和concat ,但可以使用Object.Assign来添加,而Object.keys + map减少函数来移除(实际上将对象再次作 ...
-
使用foreach合并为您的预期结果 更新1 :代码的简化版本 if(count($_POST['id'])==count($_POST['hruleid'])) { foreach ($_POST['id'] as $key => $value) { $new_array[] = array('id'=>$value,'rule_id'=>$_POST['hruleid'][$key]); } } 旧更新:我会这样做: db.yourcollection.find().snapshot().forEach( function (e) { var saveChanges = false; if(e.cards && e.cards.length > 0){ for(var i=0; i < e.cards.length; i++){ if(e.cards[i].expiration_month && e.cards[i].expiration_yea ...
将两个数组组合成结果数组中的键和值?(Combine two arrays into keys and values in a resulting array? [duplicate])[2023-11-23]
使用array_combine() : $a = array('green', 'red', 'yellow'); $b = array('avocado', 'apple', 'banana'); $c = array_combine($a, $b); print_r($c); ?> Array ( [green] => avocado [red] => apple [yellow] => banana ) Use array_combine(): $a = arr ...由于您很可能想从远程服务中获取部门和位置列表(发出另一个HTTP请求),因此我会立即使用Observables执行此操作。 Observable.from(persons) .mergeMap(person => { let department$ = Observable.from(departments) .filter(department => department.departmentID == person.departmentID); ...您可以通过创建新对象来跟踪每个键的存在来计算每个键值出现的次数。 var set = {}; var changedArray = existingArray.map(function(d){ // since each object has one key var key = Object.keys(d)[0]; // if the key doesn't exist, add it. if it does, increment it set[key] = (set[ ...如何将具有相同键的对象数组组合成一个对象?(How can I combine an array of objects with the same keys into one object?)[2022-05-04]
直接JavaScript代码(无库)的答案: var result = {}; for (var i = 0; i < people.length; i++) { var item = people[i]; for (var key in item) { if (!(key in result)) result[key] = []; result[key].push(item[key]); } } An answer in s ...这是一个简单的强制性解决方案: $combined = array(); foreach ($array1 as $v) { if (isset($array2[$v])) { $combined[$v] = $array2[$v]; } } 而功能解决方案: // Note that elements of $combined will retain the order of $array2, not $array1 $combined = array_intersec ...相关文章
更多- Solr Multicore 结合 Solr Distributed Searching 切分...
- eclipse里报:An internal error occurred during:
- Solr Multicore 结合 Solr Distributed Searching 切分大索引来搜索
- syntax error near unexpected token的解决办法
- The connection to adb is down, and a severe error has occured.
- 转载--solr的searching过程(1)
- solr error logs org.apache.solr.common.SolrException: ERROR: [doc=17] unknown field alias
- win8安装VirtualBox-4.2.18提示Installation failed!error:系统找不到指定的路径
- solr 4.4 Error filterStart 问题
- [Hadoop] Error: JAVA_HOME is not set
最新问答
更多- 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
- 如何通过引用返回对象?(How is returning an object by reference possible?)
- 矩阵如何存储在内存中?(How are matrices stored in memory?)
- 每个请求的Java新会话?(Java New Session For Each Request?)
- css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
- 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
- xcode语法颜色编码解释?(xcode syntax color coding explained?)
- 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
- 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
- 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
- 西安哪有PLC可控制编程的培训
- 在Entity Framework中选择基类(Select base class in Entity Framework)
- 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
- 电脑二级VF有什么用
- Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
- 金华英语角.
- 手机软件如何制作
- 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
- 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
- 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
- Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
- 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
- python的访问器方法有哪些
- DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
- 在Ruby中对组合进行排序(Sorting a combination in Ruby)
- 网站开发的流程?
- 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
- 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
- 透明度错误IE11(Transparency bug IE11)
- linux的基本操作命令。。。