When I execute the code below, I get the common exception The process cannot access the file *filePath* because it is being used by another process.
What is the most efficient way to allow this thread to wait until it can safely access this file?
Assumptions:
the file has just been created by me, so it is unlikely that another app ...
I've been toying around with libevent2, and I've got reading files working, but it blocks. Is there any way to make file reading not block just within libevent. Or, do I need to use another IO library for files and make it pump events that I need.
fd = open("/tmp/hello_world",O_RDONLY);
evbuffer_read(buf,fd,4096);
The O_NONBLOCK flag ...
I write my debug information to a file using a separate thread. During startup, I like to backup any previous file. Unfortunately, it seems the OS hangs onto the file handle for an indeterminate amount of time so when I try to write to the file, it fails.
I am using C#, .Net framework 3.5 on Windows XP. (Vista and Win7 have the sam...
I'm trying to use Python to concatenate a few javascript files together before minifying them, basically like so:
outfile = open("output.js", "w")
for somefile in a_list_of_file_names:
js = open(somefile)
outfile.write(js.read())
js.close()
outfile.close()
The minifier complains about illegal characters and syntax errors a...
I have an HTML document stored in a file, with a UTF-8 encoding, and I want my extension to display this file in the browser, so I call loadURIWithFlags('file://' + file.path, flags, null, 'UTF-8', null); but it loads it as ISO-8859-1 instead of UTF-8. (I can tell because ISO-8859-1 is selected on the View>Character Encoding menu, and be...
One of my applications downloads a database from a server.
When I install the application onto my phone, it downloads the file correctly and loads the information, no exceptions thrown or anything.
However, when I upload the apk into the Android Market Place and download it onto the phone, the application downloads the database and then...
In C, I want to process a file that contains 108 16-digit alphanumeric strings and determine if each one is unique in the file. How can I do that?
...
---- PLEASE CLOSE ----
------ Edit ---------
I found where the problem is. I'm going to start a new question for the real problem ....
----------------------
Hi,
My Situation:
Linux (Ubuntu 10.04)
gcc
But it has to be platform independent
I have a text file (UTF-8) with special characters like ¥ © ® Ỳ È Ð. I have a std:...
I'm a physicist that normally deals with large amounts of numerical data generated using C programs. Typically, I store everything as columns in ASCII files, but this had led to massively large files. Given that I am limited in space, this is an issue and I'd like to be a little smarter about the whole thing. So ...
Is there a better f...
Can anyone recommend a fast way to sort the contents of a text file, based on the first X amount of characters of each line?
For example if i have in the text file the following text
Adrian Graham some more text here
John Adams some more text here
Then another record needs to be inserted for eg.
Bob Something some more text he...
Hello,
I have a file with thousands of lines, each one representing a point of a line. The number of chars on each line is variable. Im plotting these lines, but i only want to plot every tenth line. I know i could just do something like:
for (int k = 0; k < 9; k++) {
File.getline(buf, 1024);
}
but i was wondering if there was a...
I am trying to search for all files of a given type (say .pdf) in a given folder and copy them to a new folder. What I need to be able to do is to specify a root folder and search through that folder and all of its subfolders for any files that match the given type (.pdf). Can anyone give me a hand on how I should search through the root...
i wrote a simple function to write into a text file. like this,
def write_func(var):
var = str(var)
myfile.write(var)
a= 5
b= 5
c= a + b
write_func(c)
this will write the output to a desired file.
now, i want the output in another format. say,
write_func("Output is :"+c)
so that the output will have a meaningful nam...
I wrote this function to read a line from a file:
const char *readLine(FILE *file) {
if (file == NULL) {
printf("Error: file pointer is null.");
exit(1);
}
int maximumLineLength = 128;
char *lineBuffer = (char *)malloc(sizeof(char) * maximumLineLength);
if (lineBuffer == NULL) {
printf("Err...
I am testing some stuff out with writing to the filesystem on the Blackberry using the javax.microedition.io.file package. I am able to open a file ("file:///store/home/user/documents/mytxtfile.txt") and write to it (by that I mean that no exception is thrown, whether or not the file is created and written, I can't tell).
I am running ...
I'm browsing through a Python file pointer of a text file in read-only mode using file.readline() looking for a special line. Once I find that line I want to pass the file pointer to a method that is expecting the file pointer to be at the START of that readline (not right after it.)
How do I essentially undo one file.readline() operat...
Hey all,
Here is my situation. I would like to make writing to the file system as efficient as possible in my application. The app is multi-threaded and each thread can possibly write to the same file. Is there a way that I can write to the file asynchronously from each thread without having the writes in the different threads bang h...
I am using this code to write to a file in java. it has always worked and I am 100% sure its right. But still the file does not get written.
I don't even get an error.
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
public class writetofile {
public static void main(String [] args){
...
I'm trying to read in an Excel spreadsheet with C#/ASP.net. This entry here works great if the workbook is on my local drive.
However, when I attempt to access any workbook on a network share, I only get the first 30 rows of data.
When I used File.Copy to copy the file to the local drive of the server, I only get 35kb (and the resultin...
I'm trying to add functionality to a simple web service that will allow me to log information to an XML file on the hard drive where the application is located. When I employ the functionality in a Console version of the application, the data gets logged to:
bin\x86\Debug MySolution.MyProject\MessageLog\TestMessagess.xml.
However, w...