file

How to get a FILE* stream from a file descriptor?

We can get a file descriptor from a FILE* stream by using the fileno function. Is there a function for getting a FILE* stream from the file descriptor without reopening the file? ...

How to space a write file

Hello everyone I'm currently new to python, and I'm trying to write a program where the user can input a message and the output will show the numeric code of the message, but at the same time I need to write the numeric code to an additional file. So for example the user inputs the word "Hello" The user will see the output "72 101 108 1...

Stream large binary files with urllib2 to file

I use the following code to stream large files from the Internet into a local file: fp = open(file, 'wb') req = urllib2.urlopen(url) for line in req: fp.write(line) fp.close() This works but it downloads quite slowly. Is there a faster way? (The files are large so I don't want to keep them in memory.) ...

StreamReader to file?

I have an input stream wrapped in a System.IO.StreamReader... I wish to write the content of the stream to a file (i.e. StreamWriter). The length of the inputstream is unknown. Could be a few bytes and to gigabytes in length. How is this done the easiest that does not take up too much memory? ...

Browser download complete event

We've been looking for a while for an answer to this, but haven't found a solution. We have a web server, which allows the user to download files (pdfs), which are dynamically-generated and served from servlets. We'd like to know when a download has completed (and how: was it successful, did it fail, did the user cancel?). Is there a...

Storage-In-File Database for C#/.NET 3.5 ?

Is there something like HSQLDB (for Java) which can be run in a storage-in-file mode for C#/.NET 3.5? ...

Creating files on AppEngine

I'm trying to store some data in a binary file: import os, pickle o = some_object() file = open('test', 'wb') #this causes the error pickle.dump(o, file) file.close() I get this error: IOError: invalid mode: wb It doesn't work (neither on test server or GAE itself), apparantly because it does't have the write permission. How can I ...

Filename and mime problems - ASP.NET Download file (C#)

I'm facing a very strange problem in my ASP.NET Application. When the user clicks the button that downloads a file, Internet Explorer / Chrome / Firefox shows the save dialog but the name of the file is the name of the ASPX Page (For example, if the page is named Download.aspx the download dialog shows the "file" Download.zip). Someti...

Cannot read binary video files in GNU/Linux

Hi all. I'm stuck with an apparently harmless piece of code. I'm trying to read a whole flv video file into a uint8_t array, but by no reason only the 10 first bytes are read. contents = malloc(size + 1); if (read(fd, contents, size) < 0) { free(contents); log_message(WARNING, __func__, EMSG_READFILE); return (NULL); } I'...

header file without source file

i have written the body of the function in the header file and so do not have a source file. when i tried running my project in visual studio .. i got an error: Cannot open source file: No such file or directory. How do I make visual studio understand that the definitions of the function are within the header itself? ...

How do I unlock a folder programatically in .Net?

Basically I want to do what Unlocker does, only from code. I want to unlock all access to a folder (and files under it / subfolders), so I can subsequently delete it. ...

Getting RGB values for each pixel from a 24bpp Bitmap in C

Hello, i want to read the RGB values for each pixel from a .bmp file , so i can convert the bmp into a format suitable for gba . so i need to get just the RGB for each pixel and then write this information to a file. i am trying to use the windows.h structures : typedef struct { char signature[2]; unsigned int fileSize; u...

Deleting (near) Duplicate Files

What's the best scripted way to delete (near) duplicate files based on filespec in Windows (XP in this case)? I am thinking of RegEX and some VB Script but if there is a better way... Examples include filenames that slighlty differ in name either with one or two (known) extra characters at the end or beggining but are identical in size,...

How to replace the default ModelState error message in Asp.net MVC 2 ?

Hello, I need to replace the model state resource (to another language). I've seen some answers to the question above, but unfortunately I could'nt make it work. Any detailed answer or example would be appriciated. Thank you. ...

System.out.print + OS redirect vs writing to a file, which is faster?

I'm making a program that process a big file and output something to another that I need to use later. I'm wondering should I just print the output and redirect that to a file, or should I just write to the file in the program. Since this will be a very big file, I would like to know which way is faster, every bit counts. ...

Store external resources in DB??

I have database items that have 2 external resources: A.) images and B.) HTML files. Should these be stored as columns in the DB, or should the DB just hold pointers to the filesystem? What are the pros and cons of each approach? HTML files are about 200k per item, and Images are about 200k per item (5 - 10 pics or so max) Thanks. ...

Using PHP to upload an image and store data in MSSQL

Hi there, I'm attempting to upload an image as well as add details such as; title, description and filepath into a database table. I'm using the following code, but it isn't adding any data to the database; (The session.php include contains the database connectivity.) <?php include('includes/session.php'); $uploadDir = 'submitted/pic...

Where does Path.GetTempFileName(...) create files under XP?

Under Vista when you call GetTempFilePath files get created in: C:\Users\User\AppData\Local\Temp\ Does anyone know where they get created under XP? ...

How to Replace a line in the same file by SED in Unix Shell scripting?

Hi In Reference to this question After getting the line identifier matching in first and second file I need to replace the line in first file with the line of second file.For that I am using SED as below. But Sed only replaces that line in a new file. How can I achieve the updation in same file without temporary file.(Because those are v...

Non-intrusively unlock file on Windows

Is there a way to unlock a file on Windows with a Python script? The file is exclusively locked by another process. I need a solution without killing or interupting the locking process. I already had a look at portalocker, a portable locking implementation. But this needs a file handle to unlock, which I can not get, as the file is alre...