files

How to detect new or modified files

I found there are two ways to approach it, ReadDirectoryChangesW and FindFirstChangeNotification, I want to know what’s difference between them, performance or other??? ...

Cron Job - Command to delete all .flv files everyday

Hello all, I have this command that I run everyday via cron: find /home/get/public_html/videos -daystart -maxdepth 0 -mtime +1 -type f -name "*.flv" |xargs rm -f The problem is that it doesn't delete the .flv files in a directory that are 1 or more days old. How can I correct the above command? EDIT: Paul - the command "ls -l /ho...

Deleting files using a service application

I am using a FileSystemWatcher in VS2005 to monitor directories and thought to change the application to a service. Eveverything woks fine until the service tries to delete a file. Sending the exception to the eventviewer, I get a System.UnauthorizedAccessException. The file in question (testing) can be deleted by the same FileSystemWatc...

How to export data as CSV format from SQL Server using sqlcmd?

I can quite easily dump data into a text file such as: sqlcmd -S myServer -d myDB -E -Q "select col1, col2, col3 from SomeTable" -o "MyData.txt" However, I have looked at the help files for sqlcmd but have not seen an option specifically for CSV. Is there a way to dump data from a table into a CSV text file using sqlcmd? ...

How to get date/time when file was placed in a directory on Windows?

Is there a way to tell when a file was moved to a certain directory? I'm being asked why a script of mine did not find a file in a certain directory. The file was created last January but I suspect it was placed in the directory after the script was run. Is there a way for me to confirm my suspicion? Viewing the file properties gives...

What is the best/simplest way to read in an XML file in Java application?

Currently our Java application uses the values held within a tab delimited *.cfg file. We need to change this application so that it now uses an XML file. What is the best/simplest library to use in order to read in values from this file? ...

Reading files in C#, differences in methods

Studying C#, my books are showing me classes for readin files. I've found 2 that are very similar and the Visual Studio debugger doesn't show an obvious difference between the two. code: FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read); FileStream fs = File.Open(path, FileMode.Open, FileAccess.Read); Now I wond...

How can I scan multiple log files to find which ones have a particular IP address in them?

Recently there have been a few attackers trying malicious things on my server so I've decided to somewhat "track" them even though I know they won't get very far. Now, I have an entire directory containing the server logs and I need a way to search through every file in the directory, and return a filename if a string is found. So I tho...

file uploading problem with open_basedir and move_uploaded_file

I'm working with a legacy php script. There is a file upload form in it already, but I've added another one for a different section in the same script. The $_file['file'] is there. But I keep getting a open_basedir restriction error, and if not that, I get a permission error. I wouldn't mind working around these problems, but the thing...

Delphi fast file copy

Hey, I'm writing an app that supposed to copy a bunch of files from one place to another. When I'm using TFileStream for the copy it is 3-4 times slower than copying the files with the OS. I also tried to copy with a buffer, but that was too slow aswell. I'm working under Win32, anyone got some insights on this matter? ...

How do I unlock a folder/file under Linux

Today I had the problem that I couldn't delete a folder because "it was busy". How can I find out which application to blame for that or can I just delete it with brute force? ...

.NET How to check if path is a file and not a directory?

I have a path and I need to determine if it is a directory or file. Is this the best way to determine if the path is a file? string file = @"C:\Test\foo.txt"; bool isFile = !System.IO.Directory.Exists(file) && System.IO.File.Exists(file); For a directory I would reverse the logic. string directory = @"C:...

Windows Mobile File Time

In Windows Mobile I am using FindFirstFile/FindNextFile to search for some files. As part of the results I am getting a WIN32_FIND_DATA structure which contains one search result. This structure contains 3 FILETIME structures for file creation, last write and last access times. Then I am converting these structures to SYSTEMTIME using ...

How do you insert a file (PDF) into a varbinary SQL Server column and later retrieve it?

I'm looking to take the results of a report run (a PDF file from Crystal Reports), serialize it, stick it into a varbinary field, and then later be able to deserialize it and present it back to the user. For now I have to just plain old ADO .NET (SqlClient, SqlCommand, etc.) Are there any pitfalls to this? What is the basic syntax to a...

What would be the fastest way to concatenate three files in C# ?

Hello everyone! I need to concatenate 3 files using C#. A header file, content, and a footer file, but I want to do this as cool as it can be done. cool = really small code or really fast (non-assembly code). ...

Change command to one that does not fork and use up resources

Hello all, I have the following command which deletes files that are one day old and that are of mp3 file type. find /home/get/public_html/audio -daystart -maxdepth 1 -mtime +1 -type f -name "*.mp3" |xargs rm -f The problem with this is when i run it, it sometimes says "fork": resource xargs not available. Does this mean, t...

Creating big file on Windows

Hi, I need to create big relatively big (1-8 GB) files. What is the fastest way to do so on Windows using C or C++ ? I need to create them on the fly and the speed is really an issue. File will be used for storage emulation i.e will be access randomly in different offsets and i need that all storage will be preallocate but not initia...

Formating file on windows

Hi, Following my question about creating files. After fast creation of large file, now i need to create a file system on this file. How can i create something like Loop device on Linux. After this i guess formatting will be really easy. Any alternative method (instead mounting) for formatting file to different FAT (12/32) and ext3 are ...

Download files using asp.net

Hello all, There is a data file and some image files that I have to download to our local servers every night using asp.net. What is the best way to do this? UPDATE Ok, after viewing the responses I see my initial post of using asp.net is a poor choice. How would you write it for a console app in C#. I am not sure what classes I am us...

What characters should be restricted from a Unix file name?

Consider a Save As dialog with a free text entry where the user enters a file name as free text, then clicks a Save button. The software then validates the file name, and saves the file if the name is valid. On a Unix file system, what rules should be applied in the validation such that: The name will not be difficult to manipulate l...