system.io.directory

Why Can't I Inherit IO.Directory?

时光总嘲笑我的痴心妄想 提交于 2019-12-24 02:41:06
问题 Why can't I create a class in VB.NET that inherits System.IO.Directory ? According to Lutz Roeder, it is not declared as NotInheritable ! I want to create a utility class that adds functionality to the Directory class . For instance, I want to add a Directory.Move function. Please advise and I will send you a six pack. OK nevermind I'm not sending you anything but if you come to the bar tonight I will hook you up and then beat you in pool. 回答1: From the Meta Data of .NET namespace System.IO {

Getting Nth sub-directory's files from an input path

爷,独闯天下 提交于 2019-12-14 03:33:20
问题 How can i Get Files from nth sub-directory of an input Directory using C#. 回答1: here is the solution i have done . and its working . foreach(var dir in Input_Folders) { string f = dir; for (int i = 0; i <= n; i++) { string path = sub_dir(f); f = path; } } n is the nth child and the method sub_dir(string) is public string sub_dir(string path) { string[] direct = Directory.GetDirectories(path); string s = direct[0]; return s; } this will go to the nth child of the each input directory .. check

Loading files from directory and add to combo box

谁都会走 提交于 2019-12-13 04:24:28
问题 I'm currently trying to add whatever files that exist in the directory into a combo box. Dim dir = "‪C:\Users\jason\Desktop\SystemFiles" For Each file As String In System.IO.Directory.GetFiles(dir) cmbTemplateFiles.Items.Add(System.IO.Path.GetFileNameWithoutExtension(file)) Next When executing this program, it says The given path's format is not supported Do I have to add new header files? Is there anything wrong with my coding? 回答1: I managed to reproduce the issue. I suppose it has to do

System.IO.Directory.CreateDirectory with permissions for only this current user?

随声附和 提交于 2019-12-11 01:14:15
问题 I want the asp application to create a folder that has access only to the account the application was running with (i.e. asp account?) I actually wanna use this one, but I don't know how to use the "Computer\CurrentAccount" dynamically. I want to get the current working account. Thanks. 回答1: There is an example of creating a DirectorySecurity instance and adding an ACE for a named user here (but use the default constructor to start with an empty ACL). To get the SID of the account there are

c# Directory.GetDirectories excluding folders

蓝咒 提交于 2019-12-07 12:56:05
问题 I'm trying to iterate through a list of users folders in windows in "c:\Users" but exclude the microsoft built-in user folders, the below is the code segment I'm using to accomplish this feat but it's for some reason not working as intended. private readonly List<String> _exclusion = new List<String> { "All Users", "Default", "LocalService", "Public", "Administrator", "Default User", "NetworkService" }; public static bool FoundInArray(List<string> arr, string target) { return arr.Exists(p =>

Directory.CreateDirectory Latency Issue?

≯℡__Kan透↙ 提交于 2019-12-06 20:52:27
问题 I'm trying to create a remote directory, and then write a file to it. Every great once in a while, the application fails with a System.IO.DirectoryNotFoundException while trying to write the file. When I write the file, I'm using the returned DirectoryInfo object to help create the file path, so the application seems to think that the directory has been created. However, the directory does not exist. Is there any chance that I'm trying to write to the directory before Windows has finished

c# Directory.GetDirectories excluding folders

本秂侑毒 提交于 2019-12-06 00:17:06
I'm trying to iterate through a list of users folders in windows in "c:\Users" but exclude the microsoft built-in user folders, the below is the code segment I'm using to accomplish this feat but it's for some reason not working as intended. private readonly List<String> _exclusion = new List<String> { "All Users", "Default", "LocalService", "Public", "Administrator", "Default User", "NetworkService" }; public static bool FoundInArray(List<string> arr, string target) { return arr.Exists(p => p.Trim() == target); } foreach (string d in Directory.GetDirectories(sDir).Where(d => !FoundInArray(

What happens with Directory.EnumerateFiles if directory content changes during iteration?

限于喜欢 提交于 2019-11-29 11:35:00
I've read discussions about difference between Directory.EnumerateFiles and Directory.GetFiles(). I understand that internally they both use System.IO.FileSystemEnumerableFactory.CreateFileNameIterator() The difference is that EnumerateFiles might use deferred execution (lazy), while GetFiles() does a ToArray, so the function is already executed. But what happens if files and folders are added to the dictionary during the iteration. Will the iteration only iterate over the items that were present during the EnumerateFiles()? Even worse: what happens if files are removed during iterations: will