I need to delete a certain line from a text file. What is the most efficient way of doing this? File can be potentially large(over million records).
UPDATE:
below is the code I'm currently using, but I'm not sure if it is good.
internal void DeleteMarkedEntries() {
string tempPath=Path.GetTempFileName();
using (var reader = new...
I support a legacy Java application that uses flat files (plain text) for persistence. Due to the nature of the application, the size of these files can reach 100s MB per day, and often the limiting factor in application performance is file IO. Currently, the application uses a plain ol' java.io.FileOutputStream to write data to disk.
...
I'm given a filename and I have to be able to read it from disk and send its contents over a network. I need to be able to determine whether the file is text or binary so I know whether to use a StreamReader or BinaryReader. Another reason why I need to know the content type is because if it is binary, I have to MIME encode the data be...
Is there a way to do a disk-based binary search for a particular key in a text file in Javascript? The text file is too big to be loaded into memory, but sorted by the key values. In particular I am looking for a way to mimic Perl's Search::Dict functionality in Javascript.
For e.g. If I have a file foo.txt:
a 1
b 10
c 5
z 4
look(c,f...
Greetings - I've got an ASP.NET application that is trying to delete a file on a network share. The ASP.NET application's worker process is running under a domain account (confirmed this by looking in TaskManager and by using ShowContexts2.aspx¹). I've been assured by the network admins that the process account is a member of a group t...
Is there a better way to check if a file is not locked then to open the file to catch an exception. I have a filewatcher running on a directory and I need to do something to the file after the file has completely moved/created in the location. Aren't throwing an exception a performance hit? Is there a better way?
Private Function FileAv...
I Googled around, but didn't find any good example / tutorial.
So i asking you SOF: How do you Read and Write to a File in C++?
...
I learning c++, started learning File Handling today. but getting a error when runinng this code
#include <iostream>
#include <fstream.h>
using namespace std;
int main()
{
fstream file;
file.open("test.txt",ios::in|ios::out)
file.close();
return 0;
}
Gets error
Cannot open include file...
How can you get the contents of a text file while preserving whether or not it has a newline at the end of the file? Using this technique, it is impossible to tell if the file ends in a newline:
BufferedReader reader = new BufferedReader(new FileReader(fromFile));
StringBuilder contents = new StringBuilder();
String line = null;
while...
I know PHP is usually used for web development, where there is no standard input, but PHP claims to be usable as a general-purpose scripting language, if you do follow it's funky web-based conventions. I know that PHP prints to stdout (or whatever you want to call it) with print and echo, which is simple enough, but I'm wondering how a P...
edit: Initially I was trying to be general but it came out vague. I've included more detail below.
I'm writing a script that pulls in data from two large CSV files, one of people's schedules and the other of information about their schedules. The data is mined and combined to eventually create pajek format graphs for Monday-Sat of peop...
I am accessing a httpwebrequest that returns a pdf file as the response. I am reading that response into a memory stream, and later on converting to a file. The problem is, is that hundreds of files are being created. Not sure why, I've tried many ways, and all do the same...
This is the first method which returns the memorystream.
...
Hi,
If I am trying to delete a file, but at the same time another process is performing a File.Exists(...) on the same file, will that potentially lock the file and cause my process to fail?
...
I'm wondering what techniques and/or library to use to implement the functionality of the linux command "tail -f ". I'm essentially looking for a drop in add-on/replacement for java.io.FileReader. Client code could look something like this:
TailFileReader lft = new TailFileReader("application.log");
BufferedReader br = new BufferedRea...
Hello,
I am heavily using byte array to transfer objects, primitive data, over the network and back. I adapt java's approach, by having a type implement ISerializable, which contains two methods, as part of the interface, ReadObjectData and WriteObjectData. Any class using this interface, would write date into the byte array. Something...
I need to serve a large file (500+ MB) for download from a location that is not accessible to the web server. I found the question Serving large files with PHP, which is identical to my situation, but I'm using Perl instead of PHP.
I tried simply printing the file line by line, but this does not cause the browser to prompt for download...
Hi,
I need to write all my program output to a text file. I believe it's done this way,
sOutFile << stdout;
where sOutFile is the ofstream object that creates the file like this:
sOutFile("CreateAFile.txt" ); // CreateAFile.txt is created.
When I insert the stdout into the sOutFile object, I get some code which seems to resemble ...
The file contains the following data:
#10000000 AAA 22.145 21.676 21.588
10 TTT 22.145 21.676 21.588
1 ACC 22.145 21.676 21.588
I tried to skip lines starting with "#" using the following code:
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
using namespace std;
int main() {
while( getline...
I want to search through existing Excel files with a macro, but I don't want to display those files when they're opened by the code. Is there a way to have them open "in the background", so to speak?
...
The following code throws an EZDecompressionError with message 'Invalid ZStream operation' whenever the line
Reader.Free
is executed. Can someone tell me what's wrong with this code?
Reader := nil;
Decompressor := nil;
InputFile := TFileStream (FileName, fmOpenRead);
try
Decompressor := TDecompressionStream.Create (InputFile);
Re...