directory

How to detect NTFS mounted folders in C#?

Once upon a time I read how you detect programmatically for mounted NTFS folders (can cause cyclic recursion when searching through folders). Now i cannot find the link.. Does anyone know how to do this? The mounting I am interested in detecting is when one folder is mounted to another folder. ...

Unix Shell scripting for copying files and creating directory

I have a source directory eg /my/source/directory/ and a destination directory eg /my/dest/directory/, which I want to mirror with some constraints. I want to copy files which meet certain criteria of the find command, eg -ctime -2 (less than 2 days old) to the dest directory to mirror it I want to include some of the prefix so I know ...

ASP.NET Deleting a directory results in application restart.

Hi, I have an application with 2 directories (books and export). If we create a book or a page of a book in the application a directory is added with the id of the page (this is for uploading resources). If we delete a page, the page (and it's directory) is removed from the database and the filesystem. However this resulted in a session...

Deleting a temporary directory in Delphi

I have this code showmessage('C:\TEMP\'+openfiles[openfilelist.ItemIndex].ID); if removedir('C:\TEMP\'+openfiles[openfilelist.ItemIndex].ID) then showmessage('Removed') else showmessage('Failed'); the message shows 'C:\TEMP\0' and this directory does exist as the program created it earlier and used files inside it and then later d...

python chdir to dir the py script is in

How do i chdir to the directory that the python script is in? so far i figured out os.chdir and sys.argv[0]. I'm sure there is a better way then to write my own func to parse argv[0] ...

Mixed language source directory layout

We are running a large project with several different languages: Java, Python, PHP, SQL and Perl. Until now people have been working in their own private repositories, but now we want to merge the entire project in a single repository. The question now is: how should the directory structure look? Should we have separate directories for...

How to append filename to current directory in Batch file?

Hi, I want to search a file in the current directory from which the batch is running, append the filename to the directory and include that entire directory as part of command that. So..... Directory: C:\tempfiles\batch Files in C:\tempfiles\batch tmp1.txt tmp2.txt tmp3.txt anyname.exe I want the batch file, run from the directory, ...

How do you set a directory to have persistent group permissions?

We have two users: user1 user2 They both belong to the group 'admin'. We have a directory that has been set to 775. The directory's group has been changed to 'admin'. Each user has full access to write into that directory, though when a user writes a new file to the directory, the group permissions of the folder are not persisted to...

Can .NET PInvoke dynamically load a native dll from a user specified directory?

I have a .NET application and need to load a native library whose location is specified by the user. PInvoke looks like it'll only load from the global search paths (or a path specified at compile time?). Would the best method be to create a C++/CLI assembly which calls LoadLibrary at runtime? Would C++/CLI be simpler than C# PInvokin...

Python - Test directory permissions

In Python on Windows, is there a way to determine if a user has permission to access a directory? I've taken a look at os.access but it gives false results. >>> os.access('C:\haveaccess', os.R_OK) False >>> os.access(r'C:\haveaccess', os.R_OK) True >>> os.access('C:\donthaveaccess', os.R_OK) False >>> os.access(r'C:\donthaveaccess', os...

How to check if directory contents has changed with PHP?

I'm writing a photo gallery script in PHP and have a single directory where the user will store their pictures. I'm attempting to set up page caching and have the cache refresh only if the contents of the directory has changed. I thought I could do this by caching the last modified time of the directory using the filemtime() function a...

python MySQL module class file name

I am confused how directory name, file name and class name all work together. This is what I have at the moment app.py database/ client.py staff.py order.py inside client.py I have a single class called client. This class acts as the database model (MVC), the same with my other files (staff.py has a class called st...

Is there any simple way to check that a path to a file is inside a certain folder (.NET framework)?

In my program I need to check that several paths to files are inside system temporary files folder (for example C:\Users\Roman\AppData\Local\Temp). I haven't found any method in System.IO.File, System.IO.Directory and System.IO.Path classes to do so. So I created my own: public static bool IsSafeToDeleteFileOrDirectory(string path) { ...

SVN: How to re-create a directory that's created but not committed yet

Here's a little SVN problem: I create a directory locally: $ svn mkdir output A output I accidentally remove it: rm -rf output Now, how do I recreate it? I tried this: $ svn mkdir output svn: 'output' is already under version control And this: $ svn revert output Reverted 'output' But it's still not there. UPDATE: P...

How do I tell a file from directory in Python?

When using os.listdir method I need to tell which item in the resulting list is a directory or just a file. I've faced a problem when I had to go through all the directories in this list, and then add a file in every single directory. Is there a way to go through this list and remove all files from it? If it isn't possible to do with ...

Comparison between two big directories

I have a large directory that contains only stuff in CS and Math. It is over 16GB in size. The types are text, png, pdf and chm. I have currently two branches: a branch of my brother's and mine. The initial files were the same. I need to compare them. I have tried to use Git, but there is a long loading time. What is the best way to co...

Using scandir() to find folders in a directory (PHP)

I am using this peice of code.. $target = 'extracted/' . $name[0]; $scan = scandir($target); To scan the directory of a folder which is used for zip uploads. I want to be able to find all the folders inside my $target folder so i can delete them and there contents, leaving only the files in the $target directory. Once i have retur...

Preventing directory traversal with web-facing application - are regular expressions bullet-proof?

I am in a situation where I need to allow a user to download a file dynamically determined from the URL. Before the download begins, I need to do some authentication, so the download has to run through a script first. All files would be stored outside of the web root to prevent manual downloading. For example, any of the following could...

How do I delete a directory with read-only files in C#?

I need to delete a directory that contains read-only files. Which approach is better: using DirectoryInfo.Delete(), or ManagementObject.InvokeMethod("Delete")? With DirectoryInfo.Delete, I have to manually turn off the read-only attribute for each file, but ManagementObject.InvokeMethod("Delete") doesn't appear to need to. Is there an...

How can I get a list of files in a directory using C or C++?

How can I determine the list of files in a directory from inside my C or C++ code? I'm not allowed to execute the 'ls' command and parse the results from within my program. ...