file

How do I lock a file in Perl?

What is the best way to create a lock on a file in Perl? Is it best to flock on the file or to create a lock file to place a lock on and check for a lock on the lock file? ...

Search and replace a line in a file in Python

I want to loop over the contents of a text file and do a search and replace on some lines and write the result back to the file. I could first load the whole file in memory and then write it back, but that probably is not the best way to do it. What is the best way to do this, within the following code? f = open(file) for line in f: ...

How do I Validate the File Type of a File Upload?

I am using <input type="file" id="fileUpload" runat="server"> to upload a file in an ASP.NET application. I would like to limit the file type of the upload (example: limit to .xls or .xlsx file extensions). Both JavaScript or server-side validation are OK (as long as the server side validation would take place before the files are bein...

Checking version of file in Ruby on Windows

Is there a way in Ruby to find the version of a file, specifically a .dll file? ...

File and directory with same name in same parent directory - Solaris 8, ufs

Ok, I have been working with Solaris for a 10+ years, and have never seen this... I have a directory listing which includes both a file and subdirectory with the same name: -rw-r--r-- 1 root other 15922214 Nov 29 2006 msheehan drwxrwxrwx 12 msheehan sysadmin 2048 Mar 25 15:39 msheehan I use file to discover contents of ...

File Replication Solutions

Thinking about a Windows-hosted build process that will periodically drop files to disk to be replicated to several other Windows Servers in the same datacenter. The other machines would run IIS, and serve those files to the masses. The total corpus size would be millions of files, 100's of GB of data. It'd have to deal with possible ...

Reading changes in a file in real-time using .NET

I have a .csv file that is frequently updated (about 20 to 30 times per minute). I want to insert the newly added lines to a database as soon as they are written to the file. The FileSystemWatcher class listens to the file system change notifications and can raise an event whenever there is a change in a specified file. The problem is t...

How to Create PCL file from MS word

How to create new PCL file similar to existing MS doc. I have Ms doc tamplate and replacing it with actual data. I need to achieve same for PCL format (Create PCL file as tamplate and replacing it with actual value from database and send it to fax). ...

Best file comparison tool

I've been using Subversion for a while now. I love it. And the feature I use the most is diff. But sometimes it is really frustrating when your comparison windows is filled with changes like: block inserted here, block deleted here. Just because you moved some methods around in your last refactoring session. All the tools I've see (Tort...

The essential steps in verifying a file upload

What would you say are the essential steps in verifying a file upload? I'd tend to check the MIME type, give it a new (random) name, make sure its got an allowed file extension, and then I'd check the contents of the file. How do you go about it? ...

Standard concise way to copy a file in Java?

It has always bothered me that the only way to copy a file in Java involves opening streams, declaring a buffer, reading in one file, looping through it, and writing it out to the other steam. The web is littered with similar, yet still slightly different implementations of this type of solution. Is there a better way that stays within...

Python - When to use file vs open

What's the difference between file and open in Python? When should I use which one? (Say I'm in 2.5) ...

Obtaining information about the physical device from a given file path

Suppose you have a full path to an accessible file or folder on the system. How can I get some kind of unique identifier for the physical device that the file (or folder) actually resides on? My first attempt was to use System.IO.DriveInfo which depends on having a drive letter. But UNC paths and multiple network drives mapped to the ...

File System Management Tools

Looking for suggestions on file system management tools. We have several terabytes of images, pdfs, excel sheets, etc. We're looking at some sort of software that will help us to manage, archive, etc the images. We don't store all the files information in a database but some are and we were hoping to maybe find an app that could help ...

How do I modify a text file in Python?

I'm using Python, and would like to insert a string into a text file without deleting or copying the file. How can I do that? ...

PHP parse_ini_file() - where does it look?

if I call php's parse_ini_file("foo.ini"), in what paths does it look for foo.ini ? the include path? the function's documentation doesn't mention it. ...

Perl - Win32 - How to do a non-blocking read of a filehandle from another process?

I'm writing some server code that talks to a client process via STDIN. I'm trying to write a snippet of perl code that asynchronously receives responses from the client's STDOUT. The blocking version of the code might look like this: sub _read_from_client { my ($file_handle) = @_; while (my $line = <$file_handle>) { print ST...

How do I wrap a string in a file in Python?

How do I create a file-like object (same duck time as File) with the contents of a string? ...

What's the simplest to way to retrieve a file over HTTP using Python?

What's the most efficient way of fetching a file from a URL using Python? ...

Best place to save user information xp and vista

I need to save a users login information in encrypted form for this application im building but im not sure of the best place to save the file. I dont want to save it into the program apps folder as i want it per user. So what is the best folder (or way) to save it into? Edit: Using c++ ...