files

How to implement a file download in asp.net

What is the best way to implement, from a web page a download action using asp.net 2.0? Log files for a action are created in a directory called [Application Root]/Logs. I have the full path and want to provide a button, that when clicked will download the log file from the IIS server to the users local pc. ...

fprintf return success but can't write to an existin file

In my codes, fprintf return successful by returning the number of bytes written in STREAM, but in the actual file the string I put is not there. ...

In Python, how do I get the path and name of the file that is currently executing?

I have scripts calling other script files but I need to get the filepath of the file that is currently running within the process. For example, let's say I have three files. Using 'execfile', script_1.py calls script_2.py. In turn, script_2.py calls script_3.py. How can I get the file name and path of script_3.py *from code within scrip...

Wait until file is unlocked in .Net

What's the simplest way of blocking a thread until a file has been unlocked and is accessible for reading and renaming? EG: Is there a WaitOnFile() somewhere in the framework? I have a service that uses a FileSystemWatcher to look for files that are to be transmitted to an FTP site, but the File Created event fires before the other proc...

How do I delete old files from a directory while keeping the most recent ones on Windows

Hello, I want to run a scheduled windows task that deletes that deletes all files from a directory that are older than 2 weeks. The reason is that these are IIS and Tomcat logs that fill up my server, but I want to keep the most recent logs in case I need to investigate a problem. Does any one know an easy way to do this? Cheers Nig...

How to get an absolute file name in Python?

Given a path such as "mydir/myfile.txt" How do I find the absolute filename relative to the current working directory in Python? E.g. on Windows, I might end up with: "C:/example/cwd/mydir/myfile.txt" ...

Finding unused files in a project

We are migrating our works repository so I want to do a cull of all the unreferenced files that exist in the source tree before moving it into the nice fresh (empty) repository. So far I have gone through by hand and found all the unreferenced files that I know about but I want to find out if I have caught them all. One way would be to ...

Why Does Path.Combine not properly concatenate filenames that start with Path.DirectorySeparatorChar

In the Immediate Window ? System.IO.Path.Combine(@"C:\test",@"test") "C:\\test\\test" ? System.IO.Path.Combine(@"C:\test",@"\test") "\\test" It seems that they should both be the same. The old FileSystemObject.BuildPath() didn't work this way... ...

C# NetCDF Library

I am currently working on (or at least planning) a couple of projects that work with large amounts of repetitive data. The kind of data that works well in a spreadsheet or database, but is nasty in XML. :) NetCDF seems like a great option for a file format. However, my work is in C# and there is no "official" NetCDF implementation avail...

How check if given string is legal (allowed) file name under Windows?

I want to include batch file rename functionality in my application. User can type destination filename pattern and (after replacing some wildcards in pattern) I need to check if it's going to be legal filename under Windows. I tried to use regular expression like [a-zA-Z0-9_]+ but it doesn't include many national-specific characters fro...

track down file handle

I have a huge ear that uses log4j and there is a single config file that is used to set it up. In this config file there is no mention of certain log files but, additional files apart from those specified in the config file get generated in the logs folder. I've searched for other combinations of (logger|log4j|log).(properties|xml) and h...

Writing more to a file than just plain text

I have always been able to read and write basic text files in C++, but so far no one has discussed much more than that. My question is this: If developing a file type by myself for use by an application I also create, how would I go about writing the data to a file and preserve the layout, formatting, etc.? Are there any standards, or...

Best approach to write/read binary data in Little or Big Endian with C#?

Ok, if i've got a binary file encoded either in little endian or big endian under .NET, what is the best way to read / write to it? In the .NET framework i've only managed to found BinaryWritters / BinaryReaders which use little endian as default, so my approach was implement my own BinaryReader / BinaryWritter for reading / writting da...

How do I convert dos files to linux files in vim?

If I open files I created in windows, the lines all end with ^M. How do I delete them all in once? ...

How to insert characters to a file using C#

I have a huge file, where I have to insert certain characters at a specific location. What is the easiest way to do that in C# without rewriting the whole file again. ...

How can I get Eclipse to show .* files?

By default, Eclipse won't show my .htaccess file that I maintain in my project. It just shows an empty folder in the Package Viewer tree. How can I get it to show up? No obvious preferences. ...

Preallocating file space in C#?

I am creating a downloading application and I wish to preallocate room on the harddrive for the files before they are actually downloaded as they could potentially be rather large, and noone likes to see "This drive is full, please delete some files and try again." So, in that light, I wrote this. // Quick, and very dirty System.IO.File...

Letting several assemblies access the same text file

I've got many assemblies/projects in the same c#/.net solution. A setting needs to be saved by people using the web application gui, and then a console app and some test projects need to access the same file. Where should I put the file and how to access it? I've tried using "AppDomain.CurrentDomain.BaseDirectory" but that ends up being...

Getting a FILE* from a std::fstream

Is there a (cross-platform) way to get a C FILE* handle from a C++ std::fstream ? The reason I ask is because my C++ library accepts fstreams and in one particular function I'd like to use a C library that accepts a FILE*. ...

Directory Modification Monitoring

I'm building a C# application that will monitor a specified directory for changes and additions and storing the information in a database. I would like to avoid checking each individual file for modifications, but I'm not sure if I can completely trust the file access time. What would be the best method to use for getting recently modi...