getfiles

C# return full path with GetFiles

拟墨画扇 提交于 2019-12-23 19:48:27
问题 Use this code for search files in directory: FileInfo[] files = null; string path = some_path; DirectoryInfo folder = new DirectoryInfo(path); files = folder.GetFiles("*.*", SearchOption.AllDirectories); This return only filename and extension (text.exe). How to return full path to file(C:\bla\bla\bla\text.exe)? If I use Directory.GetFiles("*.*") , this return full path. But if folder contains point in name(C:\bla\bla\test.0.1), result contains path to folder without file: 0 C:\bla\bla\bla

How to get files from exact subdirectories

南楼画角 提交于 2019-12-23 11:56:58
问题 I've managed to get files out of "root" folder subdirectories, but I also get files from these subdirectories directories2, which I don't want to. Example: RootDirectory>Subdirectories (wanted files)>directories2 (unwanted files) I've used this code: public void ReadDirectoryContent() { var s1 = Directory.GetFiles(RootDirectory, "*", SearchOption.AllDirectories); { for (int i = 0; i <= s1.Length - 1; i++) FileInfo f = new FileInfo(s1[i]); . . . etc } } 回答1: Try this : var filesInDirectSubDirs

Python Paramiko SFTP get file along with file timestamp/stat

放肆的年华 提交于 2019-12-21 21:31:34
问题 # create SSHClient instance ssh = paramiko.SSHClient() list = [] # AutoAddPolicy automatically adding the hostname and new host key ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.load_system_host_keys() ssh.connect(hostname, port, username, password) stdin, stdout, stderr = ssh.exec_command("cd *path*; ls") for i in stdout: list.append(i) sftp = ssh.open_sftp() for i in list: tempremote = ("*path*" + i).replace('\n', '') templocal = ("*path*" + i).replace('\n', '') try: #Get

Python Paramiko SFTP get file along with file timestamp/stat

元气小坏坏 提交于 2019-12-21 21:27:14
问题 # create SSHClient instance ssh = paramiko.SSHClient() list = [] # AutoAddPolicy automatically adding the hostname and new host key ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.load_system_host_keys() ssh.connect(hostname, port, username, password) stdin, stdout, stderr = ssh.exec_command("cd *path*; ls") for i in stdout: list.append(i) sftp = ssh.open_sftp() for i in list: tempremote = ("*path*" + i).replace('\n', '') templocal = ("*path*" + i).replace('\n', '') try: #Get

How to skip folders with unauthorized access while creating fileinfo list? [duplicate]

一笑奈何 提交于 2019-12-20 03:27:11
问题 This question already has answers here : Getting files recursively: skip files/directories that cannot be read? (3 answers) UnauthorizedAccessException cannot resolve Directory.GetFiles failure [duplicate] (7 answers) Closed 6 years ago . I have this for finding files and listing to list .but when it comes to a folder that needs authorized access, it stops. How can I make this skip those folders and carry on? string[] filetypes = new string[] { "3gp", "avi", "dat", "mp4", "wmv", "mov", "mpg",

UnauthorizedAccessException while getting files

坚强是说给别人听的谎言 提交于 2019-12-18 09:17:27
问题 I am creating an application which finds duplication in files. When I search files like: try { string[] allFiles = Directory.GetFiles( directoryPath, "*.*", SearchOption.AllDirectories ); for (int i = 0; i < allFiles.Length; i++) { //decisions } } catch (UnauthorizedAccessException ex) { MessageBox.Show(ex.Message); } it says Access to path 'C:\$Recycle.Bin....... ' is denied. I want if a folder is not accessible then move to the next but execution of program stops at Directory.GetFiles

Directory.GetFiles of certain extension

情到浓时终转凉″ 提交于 2019-12-17 05:53:44
问题 Is there a way to simplify this linq expression, or is there a better way of doing this? Directory.GetFiles(dir, "*.*", SearchOption.AllDirectories) .Where(s => s.EndsWith(".jpg", StringComparison.OrdinalIgnoreCase) || s.EndsWith(".gif", StringComparison.OrdinalIgnoreCase) || s.EndsWith(".png", StringComparison.OrdinalIgnoreCase) || ...); Basically I want to return all files of a certain extension. Unfortunately, this method isn't very flexible. I'd rather be able to add extensions to a list

GetFiles with multiple extensions [duplicate]

有些话、适合烂在心里 提交于 2019-12-17 02:23:05
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Can you call Directory.GetFiles() with multiple filters? How do you filter on more than one extension? I've tried: FileInfo[] Files = dinfo.GetFiles("*.jpg;*.tiff;*.bmp"); FileInfo[] Files = dinfo.GetFiles("*.jpg,*.tiff,*.bmp"); 回答1: Why not create an extension method? That's more readable. public static IEnumerable<FileInfo> GetFilesByExtensions(this DirectoryInfo dir, params string[] extensions) { if

Error using load; Unable to read file matlab

醉酒当歌 提交于 2019-12-13 02:21:59
问题 I am trying to open a dialog box that prompts the user to select a file and then using that file in a function written for a matlab toolbox called EEGLAB. The code is as follows: [F,PathName,FilterIndex] = uigetfile({'*.*','All Files(*.*)'}, 'Select your File ') b = strcat(PathName,F) Input = importdata(b) FF = Input.filename; %Loading the dataset into EEG lab. and rereferencing to Cz. EEG = pop_loadset('filename','FF','filepath','/Users/maheensiddiqui/Desktop/eeglab13_4_4b/EEG_data/Data

Multiple filters with Directory.GetFiles?

六月ゝ 毕业季﹏ 提交于 2019-12-11 16:13:35
问题 I'm trying to use multiple filters with the Directory.GetFiles() command. So say I want to match both .html and .css files. I'm using this: Directory.GetFiles(path,"*.html|*.css"); I don't see any documentation however that this is supported, and it ends up not matching either HTML or CSS files. Is there something I'm missing? 回答1: The Directory.GetFiles function doesn't support multiple filters. My solution: string patter = "*.jpg|*.png|*.gif"; string[] filters = patter.Split('|'); foreach