directory

C# delete a folder and all files and folders within that folder

断了今生、忘了曾经 提交于 2019-12-18 10:13:19
问题 I'm trying to delete a folder and all files and folders within that folder, I'm using the code below and I get the error Folder is not empty , any suggestions on what I can do? try { var dir = new DirectoryInfo(@FolderPath); dir.Attributes = dir.Attributes & ~FileAttributes.ReadOnly; dir.Delete(); dataGridView1.Rows.RemoveAt(dataGridView1.SelectedRows[i].Index); } catch (IOException ex) { MessageBox.Show(ex.Message); } 回答1: dir.Delete(true); // true => recursive delete 回答2: Read the Manual:

How to rename a virtualenv in Python?

孤街浪徒 提交于 2019-12-18 10:11:33
问题 I misspelled the name of the virtualenv while initializing it using: $ virtualenv vnev I actually intended to create the environment with the name venv . Having tried to rename the vnev folder to venv , I find that this doesn't provide much help. The name of the activate environment still renames the old vnev . $ mv vnev venv $ . venv/bin/activate (vnev) $ deactivate I would like to know how to go about renaming the environment? 回答1: By default virtualenv does not support the renaming of

Popular folder structure for build

感情迁移 提交于 2019-12-18 10:02:34
问题 I am wondering what the popular or best way to organise your build assets and source code within a project is? 回答1: Personaly I use /client/projectname/trunk/source/Solution Name.sln /client/projectname/trunk/source/Project.One /client/projectname/trunk/source/Project.Two /client/projectname/trunk/source/Project.Three /client/projectname/trunk/source/SQL/ /client/projectname/trunk/source/SQL/SomeScript.sql /client/projectname/trunk/libraries /client/projectname/trunk/resources/Nunit /client

How to create a directory using Ansible

痴心易碎 提交于 2019-12-18 09:55:13
问题 How do you create a directory www at /srv on a Debian-based system using an Ansible playbook? 回答1: You want the file module. To create a directory, you need to specify the option state=directory : - name: Creates directory file: path: /src/www state: directory You can see other options at http://docs.ansible.com/file_module.html 回答2: You can even extend the file module and even set the owner,group & permission through it. (Ref: Ansible file documentation) - name: Creates directory file: path:

EXCEL VBA code to retrieve sharedmailbox all mails from root folders to subfolders

旧巷老猫 提交于 2019-12-18 09:44:51
问题 I have a code currently which I think should pull all mail items specified from only default folder. It's not working as I expected. I know there is some problem in looping all folders in shared mail box from root. How can fix it? Dim OutlookApp As Outlook.Application Dim OutlookNamespace As Outlook.Namespace Dim olShareName As Outlook.Recipient Dim Folder As MAPIFolder Dim eFolder As Outlook.Folder Dim olItems As Outlook.Items Dim OutlookMail As Variant Dim arrResults() As Variant Dim

Foreach file in directory jQuery

假装没事ソ 提交于 2019-12-18 09:26:11
问题 How can I do a foreach(File file in Directory) kind of thing in jQuery. Thank you! 回答1: Javascript does not have access to the local file system for obvious security reasons. This is not possible. Unless you are trying to loop through files on your server, in which case you wouldn't want to use jQuery anyway but something like ASP.NET or PHP or whatever framework you are using. 回答2: $('selector').each(function(idx, elm){ //some code }); Will allow you to iterate over a list, applying the same

How can I check if a given directory is accessible?

风格不统一 提交于 2019-12-18 09:25:59
问题 I am currently writing a script that will list all specific files in a directory. What I need the script to do is to verify that the directory is accessible. I am currently using this bit of code: # variable used to get the file permissions of the given directory perm=$(stat -c %a "$dir_name") if [ "$perm" != "755" -o "$perm" != "777" ]; then echo ERROR: "Directory $dir_name cannot be accessed check permissions" echo USAGE: "ass2 <directory>" exit 3 fi This will work for checking if they have

DirectoryInfo.Delete vs Directory.Delete

情到浓时终转凉″ 提交于 2019-12-18 09:22:55
问题 I want to delete the contents of some temp files so I am working on small program that deletes them for me. I have these two code samples but I'm confused as to: Which code sample is better? The first sample, code1, deletes the files 1 and 2 but the second sample, code2 will delete the contains of folder 1 and 2? code1 public void DeleteContains(string Pathz) { List<DirectoryInfo> FolderToClear = new List<DirectoryInfo>(); FolderToClear.Add(new DirectoryInfo(@"C:\Users\user\Desktop\1"));

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

Python: existing file not found (IOError: [Errno 2]) when using os.walk

两盒软妹~` 提交于 2019-12-18 09:13:39
问题 I have set up the following directory: +---main | | | +---sub1 | | file1.xlsx | | | +---sub2 | | file2.xlsx | | | \---sub3 | file3.xlsx I want to access each file and compute the mean value of its A1:A10 cells, but while file1.xlsx exists, I get this error: IOError: [Errno 2] No such file or directory: 'file1.xlsx' My code as of now (it is designed to iterate over many "main" directories): import os from openpyxl import load_workbook directoryPath=r'C:\Users\MyName\Desktop\MainFolder' os