files

How to display file names from a folder

I'm using this script to display all the images in a folder, but I can't figure out how to get each image's file name to display underneath it. Any suggestions? <?php $dirname = "images"; $images = scandir($dirname); $ignore = Array(".", "..", "otherfiletoignore"); foreach($images as $curimg){ if (!in_array($curimg, $ignore)) { ...

How do I delete a read-only file?

I've got a junk directory where I toss downloads, one-off projects, email drafts, and other various things that might be useful for a few days but don't need to be saved forever. To stop this directory from taking over my machine, I wrote a program that will delete all files older than a specified number of days and logs some statistics...

What’s the best way to check if a file exists in C++? (cross platform)

I have read the answers for this question but I'm wondering if there is a better way to do this using standard c++ libs? Preferably without trying to open the file at all. Edit: Thanks for the answers so far, but I'm still stuck... Both "stat" and "access" is pretty much ungoogleable. What should I #include to use these? ...

Rename file onto another in java

I have a file I need to rename to that of an existing file. This is a copy, modify, replace original operation on an existing JAR file. I've got the first two steps done, I just need help with the replace original bit. What's the best way to rename the new version of the JAR to that of the old. The old JAR doesn't need preserving and I d...

.NET Forms Authentication: How to limit access to resources like pdf files to authenticated users only

I am using .net2.0 and IIS6. When using .net Forms Authentication: How to limit access to resources like pdf files to authenticated users only; so in order to access a file say mysite.com/mydoc.pdf they would have to be authenticated first (go through the login page) It seems that by default only the .aspx pages are protected. E.g. to...

Dos and don'ts of using files

I am preparing a lecture on files for the more junior students in programming class. One of the points I want to elaborate are good practices with files. What are the thing to keep in mind when using files in any programming language? ...

Best way to read structured binary files with Java

I have to read a binary file in a legacy format with Java. In a nutshell the file has a header consisting of several integers, bytes and fixed-length char arrays, followed by a list of records which also consist of integers and chars. In any other language I would create structs (C/C++) or records (Pascal/Delphi) which are byte-by-by...

Accounting for a changing path

In relation to another question, how do you account for paths that may change? For example, if a program is calling a file in the same directory as the program, you can simply use the path ".\foo.py" in *nix. However, apparently Windows likes to have the path hard-coded, e.g. "C:\Python_project\foo.py". What happens if the path changes?...

How to monitor / log files access to remote folders under windows ?

Hello, I would like to log the name of all the files I access from a particular network share (and the process accessing the the file). What are the solutions in C++ / Win32 preferably ? Kind Regards, Bear ...

Executable reading itself

I need to read data added to the end of an executable from within that executable . On win32 I have a problem that I cannot open the .exe for reading. I have tried CreateFile and std::ifstream. Is there a way of specifying non-exclusive read access to a file that wasn't initially opened with sharing. EDIT- Great thing about stackoverflo...

Inserting text into an existing file via Java

Hello, I would like to create a simple program (in Java) which edits text files - particularly one which performs inserting arbitrary pieces of text at random positions in a text file. This feature is part of a larger program I am currently writing. Reading the description about java.util.RandomAccessFile, it appears that any write ope...

Display imagenames

Hello, I would like to display the names of the images in an imagemap. In other words: read, in a loop, the content of a map. Jac ...

How do you monitor file access and changes on a file server by user name?

I was asked to find a way to monitor changes (modification, renaming, deletion, moving) of files in specific folders on the company's shared file server (simple windows shared directory). I wrote a simple app in C# that uses FileSystemWatcher to monitor these changes and notify a particular email address of them. What I'd like to know n...

Search directory in SVN for files with specific file extension and copy to another folder?

I would like my python script to search through a directory in SVN, locate the files ending with a particular extension (eg. *.exe), and copy these files to a directory that has been created in my C drive. How can I do this? I'm new to Python so a detailed response and/or point in the right direction would be very much appreciated. Fol...

How do I get list of all filenames in a directory using VB6?

What is the simplest way in VB6 to loop through all the files in a specified folder directory and get their names? ...

PHP and concurrent file access

I'm building a small web app in PHP that stores some information in a plain text file. However, this text file is used/modified by all users of my app at some given point in time and possible at the same time. So the questions is. What would be the best way to make sure that only one user can make changes to the file at any given point ...

How do I copy files with specific file extension to a folder in my python (version 2.5) script?

I'd like to copy the files that have a specific file extension to a new folder. I have an idea how to use os.walk but specifically how would I go about using that? I'm searching for the files with a specific file extension in only one folder (this folder has 2 subdirectories but the files I'm looking for will never be found in these 2 su...

How to Check if File is ASCII or Binary in C++

So using the system command file we can use file to determine if a file is ASCII Text or "data". I wanted to know if there is a way to check in code which one it was? I want to basically throw a corrupt error if the file is 'data'. I am using ifstream for reading the files. Thanks for any help! Duplicate of this question. ...

How do I remove a specific number of files using python (version 2.5)?

I would like to remove two files from a folder at the conclusion of my script. Do I need to create a function responsible for removing these two specific files? I would like to know in some detail how to use os.remove (if that is what I should use) properly. These two files will always be discarded at the conclusion of my script (which p...

How do I zip the contents of a folder using python (version 2.5)?

Once I have all the files I require in a particular folder, I would like my python script to zip the folder contents. Is this possible? And how could I go about doing it? A point in the right direction (i.e. a link with an example) or an example that I can see would be extremely helpful. Thanks in advance. ...