directory

How to delete the symlink along with the source directory

那年仲夏 提交于 2019-12-23 20:54:05
问题 I would like to delete the symlink along with the source directory. For example - ls -lrt testsymlink -> /user/temp/testdir I would like to remove both testsymlink and /user/temp/testdir . Consider that I know the only the symlink name. Any utility with python will do great. 回答1: You can use the result of os.path.realpath to detect and delete the symlink target. Example: import os # ./foo -> ./bar filepath = "./foo" if (os.path.realpath(filepath) != filepath): targetpath = os.path.realpath

\Windows\ versus \Windows\System32 - File location conventions

倖福魔咒の 提交于 2019-12-23 20:50:37
问题 Is there a standard convention for the types of files that go in \Windows\ versus those that go in \Windows\System32 ?? I'm working on an SDK that has a variety of DLLs a helper exe, and a Windows service exe. The previous guy who worked on the code put the two exe files in \Windows\ and the DLLs in \Windows\System32\ But it seems to me that they should likely all go in \Windows\System32\ Which would you do? Edit: I am NOT trying to debate the merits of if they should go there at all. Plenty

Wix: Set permission of a folder within the installfolder using permissionEx

邮差的信 提交于 2019-12-23 20:34:02
问题 I'm creating an installer for an ASP.NET MVC web app using Wix, and I need to set a write permissions for the IIS_WPG on a particular folder in the site. I found an example (I think, still haven't got it working) of how to do this with cacls.exe: <CustomAction Id="PermissionAppData" Directory="TARGETDIR" ExeCommand=""[SystemFolder]cacls.exe" "[INSTALLDIR]\Content\uploads" /T /E /G IIS_WPG:M" Return="check" /> However, I've heard that PermissionEx is better as it modifies ACLs instead of

Building a directory tree from a list of file paths

扶醉桌前 提交于 2019-12-23 19:53:32
问题 I am looking for a time efficient method to parse a list of files into a tree. There can be hundreds of millions of file paths. The brute force solution would be to split each path on occurrence of a directory separator, and traverse the tree adding in directory and file entries by doing string comparisons but this would be exceptionally slow. The input data is usually sorted alphabetically, so the list would be something like: C:\Users\Aaron\AppData\Amarok\Afile C:\Users\Aaron\AppData\Amarok

VB 6 Checking if a file on the network exists takes too long

限于喜欢 提交于 2019-12-23 19:53:24
问题 The following code: If FileExists(XCustPath + "XCust.dat") Then XCustRun End If and this code: Public Function FileExists(ByVal Fname As String) As Boolean Dim lRetVal As Long Dim OfSt As OFSTRUCT lRetVal = OpenFile(Fname, OfSt, OF_EXIST) If lRetVal <> HFILE_ERROR Then FileExists = True Else FileExists = False End If End Function XCustPath points to a mapped network location with the file XCust.dat inside it. But on the line: lRetVal = OpenFile(Fname, OfSt, OF_EXIST) It takes forever and

How to exclude file types from Directory Iterator loop

半腔热情 提交于 2019-12-23 19:14:17
问题 Simple directory iterator that is recursive and shows all files and directories/sub-directories. I don't see any built in function to exclude certain file types, for instance in the following example I do not want to output any image related files such as .jpg , .png , etc. I know there are several methods of doing this , looking for advice on which would be best. $scan_it = new RecursiveDirectoryIterator("/example_dir"); foreach(new RecursiveIteratorIterator($scan_it) as $file) { echo $file;

Display all images from outside web root folder using PHP

青春壹個敷衍的年華 提交于 2019-12-23 19:02:02
问题 I want to display all images that are stored outside my web root folder. Please help me. I am only able to display one image repeatedly. For example, if I have 5 images in my folder, only one image is displayed on my browser 5 times. Please help me on this. I've been working on this problem for over a month now. I'm a newbie. Help. Thank you. Here is the code I'm using. images.php <?php // Get our database connector require("includes/copta.php"); // Grab the data from our people table $sql =

direct.h documentation

流过昼夜 提交于 2019-12-23 18:02:51
问题 I'm trying to write a small block of code that prints out the files in a given directory. I've seen references to using the direct.h library to do this, but I cannot find any documentation whatsoever on the header file and its methods. Is this library outdated? And is there another way to list all filenames of a directory in C++? 回答1: It seems that this header functions are not designed for this task, See http://msdn.microsoft.com/en-us/library/as5kw0ze(v=vs.110).aspx Use FindFirstFile,

C# SharpZipLib strips irrelevant directory names

放肆的年华 提交于 2019-12-23 17:30:57
问题 I am using SharpZipLib to zip up a folder with subdirectories and this is working fine. What I would like to do is strip off the parents directories of the first child file so the whole structure that is irrelevant isn't carried forth... Example: c:\a\b\c\d\e\f\g\h\file1.txt c:\a\b\c\d\e\f\g\h\file2.txt c:\a\b\c\d\e\f\g\h\i\file1.txt c:\a\b\c\d\e\f\g\h\i\file2.txt It should end up like this: file1.txt file2.txt i\file1.txt i\file2.txt How can I do this? Here is the code I have so far: ZipFile

cmd命令和dos命令有什么不同?

假如想象 提交于 2019-12-23 17:18:22
知识点笔记: cmd 在windows下是DOS模拟器,能运行绝大部分DOS命令,但是不是真正的DOS,DOS是一个操作系统,而CMD只是在WINDOWS下面模拟DOS环境。 一、CMD命令 1 . services.msc 查看和设置本地服务; 2 . mspaint 打开画图工具; 3 . calc 打开计算机 二、DOS命令 dir (directory) :列出当前目录下的文件以及文件夹 md (make directory): 创建目录 rd (remove directory):删除目录 cd (change directory):进入指定目录 cd.. : 退回到上一级目录 cd\ : 退回到根目录 del:删除文件 exit:退出dos命令行 cls (clear screen): 清屏 ipconfig : 查看ip网络配置; telnet: 查看端口是否开通; 格式: telnet ip 端口号。 ping命令: 是用来测试网络之间是否能够连通以及网络之间的传输速度。 例:测试网卡,TCP/IP协议是否可用,如果发送的数据包数目等于接收的数据包数目(也就是本机能够接收到目的地址发送的数据包),就证明网卡正常,TCP/IP协议可用。 127.0.0.1是本地回环地址,也就是本机地址( 自己电脑的地址 )。 ping命令实际上是通过向目的地址发送数据包