getfiles

Directory.GetFiles finds nonexisting files

烂漫一生 提交于 2021-02-06 09:53:37
问题 I just stumbled upon an undocumented behavior of the GetFiles methods in System.IO.Directory . Whenever the searchPattern parameter passed to the method contains a reserved Windows device name, such as "nul.*" or "aux.bmp" , the method returns an array containing the name of a nonexisting file, like C:\Users\ft1\nul or D:\aux , etc. I wonder if those device names have a special meaning it that context, like "." or "..", or if this is just a sort of bug. Anyway, that still seems pretty weird.

Directory.GetFiles finds nonexisting files

浪子不回头ぞ 提交于 2021-02-06 09:53:25
问题 I just stumbled upon an undocumented behavior of the GetFiles methods in System.IO.Directory . Whenever the searchPattern parameter passed to the method contains a reserved Windows device name, such as "nul.*" or "aux.bmp" , the method returns an array containing the name of a nonexisting file, like C:\Users\ft1\nul or D:\aux , etc. I wonder if those device names have a special meaning it that context, like "." or "..", or if this is just a sort of bug. Anyway, that still seems pretty weird.

Directory.GetFiles finds nonexisting files

对着背影说爱祢 提交于 2021-02-06 09:53:21
问题 I just stumbled upon an undocumented behavior of the GetFiles methods in System.IO.Directory . Whenever the searchPattern parameter passed to the method contains a reserved Windows device name, such as "nul.*" or "aux.bmp" , the method returns an array containing the name of a nonexisting file, like C:\Users\ft1\nul or D:\aux , etc. I wonder if those device names have a special meaning it that context, like "." or "..", or if this is just a sort of bug. Anyway, that still seems pretty weird.

Looking for folders in multiple extension and multiple string format

大城市里の小女人 提交于 2021-01-27 18:58:51
问题 Hi I am trying to get all the files with a set of extension and a set of string format string extensions=".exe,.txt,.xls"; string fileFormat"fileA, fileB, fileC"; let says if i have the following files in the folder fileA20200805.txt fileBxxxx.exe FileCCCCCCC.txt FileD123.xls the result should only return the first 3 files which is fileA20200805.txt fileBxxxx.exe FileCCCCCCC.txt because FileD123.xls is not in the fileFormat. I have tried the following code: Directoryinfo dInfo = new

How can I access the “Documents and Settings” folder?

夙愿已清 提交于 2020-01-09 11:13:00
问题 I'm using C# .NET 4 with VS 2010. When Iterating over some paths, I'm running this line: files = Directory.GetFiles(path, searchPattern); I get an exception when the path is the documents and settings folder. How can I access it? And no, I don't want to skip the folder with a try and catch. I want to be able to access it somehow. Edit: I got a follow up question. As I told you, I'm iterating over the paths. Is there a way to use Environment.GetFolderPath but somehow idetifying the correct

How can I access the “Documents and Settings” folder?

我是研究僧i 提交于 2020-01-09 11:09:23
问题 I'm using C# .NET 4 with VS 2010. When Iterating over some paths, I'm running this line: files = Directory.GetFiles(path, searchPattern); I get an exception when the path is the documents and settings folder. How can I access it? And no, I don't want to skip the folder with a try and catch. I want to be able to access it somehow. Edit: I got a follow up question. As I told you, I'm iterating over the paths. Is there a way to use Environment.GetFolderPath but somehow idetifying the correct

How to get selected xls file path from uri for SDK 17 or below for android?

故事扮演 提交于 2019-12-29 08:23:07
问题 I need the solution for sdk version 17 or below this is my method. public static String getRealPathFromURI_API11to18(Context context, Uri contentUri) { String[] proj = { MediaStore.Images.Media.DATA }; String result = null; CursorLoader cursorLoader = new CursorLoader( context, contentUri, proj, null, null, null); Cursor cursor = cursorLoader.loadInBackground(); if(cursor != null){ int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); cursor.moveToFirst(); result =

Retrieving files from directory that contains large amount of files

天涯浪子 提交于 2019-12-28 01:53:46
问题 I have directory that contains nearly 14,000,000 audio samples in *.wav format. All plain storage, no subdirectories. I want to loop through the files, but when I use DirectoryInfo.GetFiles() on that folder the whole application freezes for minutes! Can this be done another way? Perhaps read 1000, process them, then take next 1000 and so on? 回答1: Have you tried EnumerateFiles method of DirectoryInfo class? As MSDN Says The EnumerateFiles and GetFiles methods differ as follows: When you use

Error “URI formats are not supported” - How to pull image off web

∥☆過路亽.° 提交于 2019-12-24 10:57:03
问题 I recently wrote a piece of code like this: protected void OpenImg_Click(object sender, EventArgs e) { int i = 0; string PathToFolder = "C://LiveSite/img/XL/"; var dirInfo = new DirectoryInfo(PathToFolder); string FileName = Variables.param + "XL.jpg"; var foundFiles = dirInfo.GetFiles(FileName); if (foundFiles.Length == 1) { ClientScript.RegisterStartupScript(this.GetType(), "openFoundImage", "window.open('" + PathToFolder + foundFiles[i].Name + "');", true); } } } } It pathed correctly but

C#: Access to path <'filepath'> is denied [duplicate]

别等时光非礼了梦想. 提交于 2019-12-24 00:58:00
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Why am I getting an access denied error for the Documents and Settings folder? I have a program that will read all .exe files from a user specified folder and its sub-directories. While testing I tried to scan using C:\ as root. This threw out an "UnauthorizedAccessException was unhandled" {"Access to the path 'c:\Documents and Settings\' is denied."} The code snippet doing this is as follows: string