directoryinfo

Using DirectoryInfo.Exists is false even if the directory exists

亡梦爱人 提交于 2021-01-29 06:05:32
问题 I'm having a problem when creating a DirectoryInfo, The directory I give when creating the DirectoryInfo is this: "S:\PUBLICO\ESTUDIOS DIGITALIZADOS\PREVENTIVA\ELECTROS\2020\01-ENERO\08\" And when checking if DirectoryInfo exists it's false, even though it exists. This is a problem because it throws an exception even when using di.GetFiles(). Also, when accessing folders from 2019 instead of 2020 it works perfectly, and uses the exact same code This is the code that matters: strDirectorioBase

Append and write access to a Directory — FileIOPermission give not good result?

家住魔仙堡 提交于 2020-04-12 21:01:27
问题 I have one issue which is in fact solved, but I totally do not understand why it behaves like this. So I have a network share and I would like simply to verify if I have access to create new files and directories in that share. I have used two approaches to solve that, but in both I get different result. My test case is that I can't create files and directories on that share: Trying to create a new Directory — not a nice way try { var testPath = Path.Combine(path, testDirectory) Directory

DirectoryInfo.GetAccessControl method always fails

放肆的年华 提交于 2020-01-16 05:30:07
问题 I tried to get access information of 'current user' folder. But this code always return "method failed with unexpected error code 3, InvailedOperationException". Here is my code string CurrentUserName = System.Security.Principal.WindowsIdentity.GetCurrent().Name; var Info = new DirectoryInfo("C:\\users\\"+ CurrentUserName); var Security = Info.GetAccessControl(); 回答1: Thank you Blorgbeard. Here is the alternative code what you told. It works perfectly. string CurrentUserName = Environment

Missing directory and file info

旧时模样 提交于 2020-01-06 21:09:47
问题 The following is not returning a full list of files and directories: IEnumerable<FileSystemInfo> files = new DirectoryInfo("C:\\Windows\\System32\\drivers").EnumerateFileSystemInfos("*", SearchOption.AllDirectories); The application is run as a administrator. There are no additional file filter drivers in place. For example if I run: foreach (FileSystemInfo file in files) { Console.WriteLine(file.Name); } I get: en-US gm.dls gmreadme.txt UMDF wimmount.sys bfe.dll.mui ndiscap.sys.mui pacer.sys

Missing directory and file info

☆樱花仙子☆ 提交于 2020-01-06 21:07:34
问题 The following is not returning a full list of files and directories: IEnumerable<FileSystemInfo> files = new DirectoryInfo("C:\\Windows\\System32\\drivers").EnumerateFileSystemInfos("*", SearchOption.AllDirectories); The application is run as a administrator. There are no additional file filter drivers in place. For example if I run: foreach (FileSystemInfo file in files) { Console.WriteLine(file.Name); } I get: en-US gm.dls gmreadme.txt UMDF wimmount.sys bfe.dll.mui ndiscap.sys.mui pacer.sys

Show files from 2 different folders in a single Gridview

て烟熏妆下的殇ゞ 提交于 2019-12-31 05:25:13
问题 Is it possible to show files from 2 different folders (c:\test1 and c:\test2) in the same gridview? I work in VB.net (VS 2010) Thanks! 回答1: Yes. Get list of all the files using Directory.GetFiles() into a single IEnumerable<string> and bind it to a GridView. This is how you'll do it in c#. List<string> allFiles = new List<string>(); allFiles.AddRange(Directory.GetFiles(@"C:\test1\*")); allFiles.AddRange(Directory.GetFiles(@"C:\test2\*")); yourGV.DataSource = allFiles; yourGV.DataBind(); 回答2:

C# - How to use DirectorySecurity.SetOwner() ? I'm having troubles

被刻印的时光 ゝ 提交于 2019-12-31 04:34:07
问题 I'm having troubles figuring out the SetOwner() method. In my case, I've created an user in Active Directory by code, then, I create a folder for the user. It all works fine, but I cannot set the newly created user as the owner of the folder. I'm not a C# guru, so I'm having troubles to understand the DirectorySecurity.SetOwner() method. Can anyone please help me out? Here is the code that creates the folder, sets the rights like i want it, but I also need to set the user as the owner. string

How do i list all directories and subdirectories in an unordered list

好久不见. 提交于 2019-12-25 09:54:07
问题 I have this problem that i cant seem to overcome. i am trying to list all the directories and sub directories. This is what i have so far in code : String[] Folders; String[] Files; path = Server.MapPath("/"); DirectoryInfo dir = new DirectoryInfo(path); Folders = Directory.GetDirectories(path); try { FolderListing.Append("<ul id=\"FolderList\">"); for (int x = 0; x < Folders.Length; x++ ) { DirectoryInfo folder = new DirectoryInfo(Folders[x]); FolderListing.Append("<li>").Append(folder.Name)

Why is Application Insights saying I have a failed request, but successful

烈酒焚心 提交于 2019-12-25 08:15:23
问题 The request actually succeeds now, but AI says failed request. It took about 6 hours to get this working, i.e. creating the directory and putting data into the database. Not sure what AI's problem is. 回答1: the codelens indicator there does a query for requests the last 24 hours (or if not "configured" it is watching requests that went by while debugging ). if you click on it, it should have more information, and clicking the search link inside the popup will take you to a search window that

How do I compare one collection of files to another in c#?

天大地大妈咪最大 提交于 2019-12-23 05:45:05
问题 I am just learning C# (have been fiddling with it for about 2 days now) and I've decided that, for leaning purposes, I will rebuild an old app I made in VB6 for syncing files (generally across a network). When I wrote the code in VB 6, it worked approximately like this: Create a Scripting.FileSystemObject Create directory objects for the source and destination Create file listing objects for the source and destination Iterate through the source object, and check to see if it exists in the