getfiles

Get directory where executed code is located

对着背影说爱祢 提交于 2019-12-10 14:18:11
问题 I know that in the same directory where my code is being executed some files are located. I need to find them and pass to another method: MyLib.dll Target1.dll Target2.dll Foo(new[] { "..\\..\\Target1.dll", "..\\..\\Target2.dll" }); So I call System.IO.Directory.GetFiles(path, "*.dll") . But now I need to get know the path: string path = new FileInfo((Assembly.GetExecutingAssembly().Location)).Directory.FullName) but is there more short way? 回答1: You may try the Environment.CurrentDirectory

How can Directory.Getfiles() multi searchpattern filters c# [duplicate]

爷,独闯天下 提交于 2019-12-05 22:16:02
问题 This question already has answers here : Closed 6 years ago . Possible Duplicate: Can you call Directory.GetFiles() with multiple filters? I have a string array: string[] pattern={"*.jpg","*.txt","*.asp","*.css","*.cs",.....}; this string pattern string[] dizin = Directory.GetFiles("c:\veri",pattern); How dizin variable C:\veri directories under the directory of files assign? 回答1: You could use something like this string[] extensions = { "jpg", "txt", "asp", "css", "cs", "xml" }; string[]

PHP - Code to traverse a directory and get all the files(images)

陌路散爱 提交于 2019-12-04 06:17:23
问题 i want to write a page that will traverse a specified directory.... and get all the files in that directory... in my case the directory will only contain images and display the images with their links... something like this How to Do it p.s. the directory will not be user input.. it will be same directory always... 回答1: /** * function get files * @param $path string = path to fine files in * @param $accept array = array of extensions to accept * @param currentLevel = 0, stopLevel = 0 *

How can Directory.Getfiles() multi searchpattern filters c# [duplicate]

只愿长相守 提交于 2019-12-04 04:20:17
This question already has answers here : Closed 6 years ago . Possible Duplicate: Can you call Directory.GetFiles() with multiple filters? I have a string array: string[] pattern={"*.jpg","*.txt","*.asp","*.css","*.cs",.....}; this string pattern string[] dizin = Directory.GetFiles("c:\veri",pattern); How dizin variable C:\veri directories under the directory of files assign? You could use something like this string[] extensions = { "jpg", "txt", "asp", "css", "cs", "xml" }; string[] dizin = Directory.GetFiles(@"c:\s\sent", "*.*") .Where(f => extensions.Contains(f.Split('.').Last().ToLower()))

how to download a file from a url with javascript?

[亡魂溺海] 提交于 2019-12-02 07:42:20
how to download a file from a url with javascript? I'm trying to get from a textfield a user enters a url as follows: new Ext.form.TextField({ disabled: false, fieldLabel: "file", value:'', id:"url"}; and I need the value of this variable is the file contained in the above url I am trying as follows: var file1 = new OpenLayers.WPS.ComplexPut({ identifier: "file1", value: window.location.href = document.getElementById("url") Thanks for your answers You can use jQuery to load anything from an URL quite easily with: <script> $("#loadhere").load("http://www.google.com"); </script> is this done in

Directory.GetFiles: Show only files starting with a numeric value

半城伤御伤魂 提交于 2019-12-01 17:31:17
How can i get the Directory.GetFiles to only show me files starting with a numeric value (eg. 1abc.pdf); Directory.GetFiles(@"C:/mydir", "0-9*.pdf") To get files that start with any numeric value, regardless of the number of digits, you could use a regular expression: var files = Directory.GetFiles(@"c:\mydir", "*.pdf") .Where(file => Regex.IsMatch(Path.GetFileName(file), "^[0-9]+")); //.ToArray() <-add if you want a string array instead of IEnumerable There is no way to specify this directly in the search pattern. It's capabilities are pretty limited (mainly supports the * wildcard). The best

Directory.GetFiles: Show only files starting with a numeric value

ぃ、小莉子 提交于 2019-12-01 16:49:21
问题 How can i get the Directory.GetFiles to only show me files starting with a numeric value (eg. 1abc.pdf); Directory.GetFiles(@"C:/mydir", "0-9*.pdf") 回答1: To get files that start with any numeric value, regardless of the number of digits, you could use a regular expression: var files = Directory.GetFiles(@"c:\mydir", "*.pdf") .Where(file => Regex.IsMatch(Path.GetFileName(file), "^[0-9]+")); //.ToArray() <-add if you want a string array instead of IEnumerable 回答2: There is no way to specify

How to use DirectoryInfo.GetFiles and have it stop after finding the first match?

ε祈祈猫儿з 提交于 2019-12-01 07:31:08
Need to search the directory/sub-directories to find a file, would prefer it to stop once it has found one. Is this a feature built into DirectoryInfo.GetFiles that I am missing, or should I be using something else (self-implemented recursive search)? Use DirectoryInfo.EnumerateFiles() instead which is lazily returning the files (as opposed to GetFiles which is bringing the full file list into memory first) - you can add FirstOrDefault() to achieve what you want: var firstTextFile = new DirectoryInfo(someDirectory).EnumerateFiles("*.txt") .FirstOrDefault(); From MSDN: The EnumerateFiles and

How to use DirectoryInfo.GetFiles and have it stop after finding the first match?

假装没事ソ 提交于 2019-12-01 05:23:37
问题 Need to search the directory/sub-directories to find a file, would prefer it to stop once it has found one. Is this a feature built into DirectoryInfo.GetFiles that I am missing, or should I be using something else (self-implemented recursive search)? 回答1: Use DirectoryInfo.EnumerateFiles() instead which is lazily returning the files (as opposed to GetFiles which is bringing the full file list into memory first) - you can add FirstOrDefault() to achieve what you want: var firstTextFile = new

Get all files recursively in directories NodejS

岁酱吖の 提交于 2019-12-01 03:18:31
I have a little problem with my function. I would like to get all files in many directories. Currently, I can retrieve the files in the file passed in parameters. I would like to retrieve the html files of each folder in the folder passed as a parameter. I will explain if I put in parameter "test" I retrieve the files in "test" but I would like to retrieve "test / 1 / *. Html", "test / 2 / . / .html ": var srcpath2 = path.join('.', 'diapo', result); function getDirectories(srcpath2) { return fs.readdirSync(srcpath2).filter(function (file) { return fs.statSync(path.join(srcpath2, file))