I want to open a file which is periodically written to by another application. This application cannot be modified. I'd therefore like to only open the file when I know it is not been written to by an other application.
Is there a pythonic way to do this? Otherwise, how do I achieve this in Unix and Windows?
edit: I'll try and clarify....
Hi, how would one go about writing the contents of a structure in C++ to a text file? What I want to do is, say I have a structure called A, with data members A.one, A.two, and so on, and I want to write them out line by line into a text file, like so
Structure A
A.one = value
A.two = value
...
Structure B
B.one = value
B.two = value
...
I get an EInOutError with message 'Too many open files' when executing this code block repeatedly for some time from a number of client threads:
var InputFile : Text;
...
Assign (InputFile, FileName);
Reset (InputFile)
try
// do some stuff
finally
CloseFile (InputFile);
end;
The number of client threads is approximately 10, so on...
I'm looking for a list of each file operation. I Googled on http://www.google.se/search?q=Php+File+Operations, but didn't found anything.
Do you know a where I could find a list of PHP file operations?
$file = fopen("words.txt","**r**"); the r is once File Operation
...
I want to read unsigned bytes from a binary file.
So I wrote the following code.
#include <iostream>
#include <fstream>
#include <vector>
#include <istream>
std::string filename("file");
size_t bytesAvailable = 128;
size_t toRead = 128;
std::basic_ifstream<unsigned char> inf(filename.c_str(), std::ios_base::in | std::ios_base::binary)...
Aims
I'm trying to let users download a file (myfile.zip in this case) by clicking a button on the page, without them leaving the page - ie the browser must stay on the current page, and leave them in a position where they can continue to use the page, including clicking the button again (should they wish to get a new copy of the file)...
I want to both read and write to a file. this dont works
static void Main(string[] args)
{
StreamReader sr = new StreamReader(@"C:\words.txt");
StreamWriter sw = new StreamWriter(@"C:\words.txt");
}
How do both read and write file in C#?
...
I'm having troubles opening a Unicode file in C++ using fstreams instead of the older FILE-based file handling functions. When opening a file using _wfopen, I can specify a mode to tell it what character encoding to use. Eg:
_wfopen_s(&file, fileName, unicode ? L"r+, ccs=UTF-16LE" : L"r+" );
This works fine. When using wifstream thoug...
EDIT: Thanks all of you. Python solution worked lightning-fast :)
I have a file that looks like this:
132,658,165,3216,8,798,651
but it's MUCH larger (~ 600 kB). There are no newlines, except one at the end of file.
And now, I have to sum all values that are there. I expect the final result to be quite big, but if I'd sum it in C++,...
I have a file open for writing, and a process running for days -- something is written into the file in relatively random moments. My understanding is -- until I do file.close() -- there is a chance nothing is really saved to disk. Is that true?
What if the system crashes when the main process is not finished yet? Is there a way to do k...
Hi All,
I was wondering if there's an easy way in C++ to read a number of file names from a folder containing many files. They are all bitmaps if anyone is wondering.
I don't know much about windows programming so I was hoping it can be done using simple C++ methods.
Thanks!
...
Hi,
Is there a way to read file names from a folder using purely C(++)? That means without including windows.h (no FindFirstFile(), etc...). It doesn't look like fstream has this functionality. I know that file names are operating system dependent, but I was hoping there is some library that will allow it in windows.
Thanks!
...
I have this Xml file that i browse from my HDD into my C# program. Now the nodes of this Xml doc get displayed in a tree view in my winform. All my logic is in the winform right now. There are three methods:
To load the Xml doc in memory.
Add nodes to tree which is called by the previous method in point 1.
And event that works when i c...
Is there a standard and reliable way of creating a temporary directory inside a Java application? There's an entry in Sun's issue database, which has a bit of code in the comments, but I wonder if there is a standard solution to be found in one of the usual libraries (Apache Commons etc.)
...
Hi guys,
I've a problem!
I've a binary data that I know that is been created using Vb6, I want read all informations using C#.
How Can I do this?
I don't data structure of the file!!!
Thanks for your attention
...
Many a times we get an error, while trying to write file on Windows platform,
"The process cannot access the file 'XXX' because it is being used by another process."
How to check in C#, before writing to file that its not being used by another process?
...
In several of my apps I have code similar to the following:
if ForceDirectories(ExtractFilePath(lLogName)) then
begin
AssignFile(lLog, lLogName);
try
if FileExists(lLogName) then
Append(lLog)
else
Rewrite(lLog);
Writeln(lLog, lLogLine);
finally
{$I-}CloseFile(lLog);{$I+}
end;
e...
Okay, I'm trying to load a file in Java using this code:
String file = "map.mp";
URL url = this.getClass().getResource(file);
System.out.println("url = " + url);
FileInputStream x = new FileInputStream("" + url);
and despite the file being in the same folder as the class it says it can't find it (yes, it is in a try catch block in the...
I'm trying to rename a file after it's uploaded in the model's save method. I'm renaming the file to a combination the files primary key and a slug of the file title.
I have it working when a file is first uploaded, when a new file is uploaded, and when there are no changes to the file or file title.
However, when the title of the file...
The situation is: there is a file with 14 294 508 unsigned integers and 13 994 397 floating-point numbers (need to read doubles). Total file size is ~250 MB.
Using std::istream takes ~30sec. Reading the data from file to memory (just copying bytes, without formatted input) is much faster. Is there any way to improve reading speed withou...