0
голосов
1ответов
291 просмотров

How to read certain text containing line and then append this text to those of multiple files in which this text line is absent?

I have multiple files with *.mol extensions. In the last line in some of them there is "M END" text. I need a program reading all these files, searching for "M END" line in that files and write this "M END" to those of them which have not "M END" line at the end of file. I wrote the following...

0
голосов
4ответов
318 просмотров

File operations

I wanted move the file from one folder to another(target) folder.If the same file is already exist in target folder i wants to rename .how to implement in C#. Thanks in advance Sekar

0
голосов
2ответов
887 просмотров

Is opening a file stream a costly operation

Is opening a file stream a costly operation I'd like to provide a lazy loading functionality in a class that reads a structured file. Every element of the file has a header and a payload. the idea is to load only the headers from the file and access the payload data only when the relevent fiel...

10
голосов
5ответов
38807 просмотров

how to create a file in Java only if one doesn't already exist?

I'm trying to implement the following operation in Java and am not sure how: /* * write data (Data is defined in my package) * to a file only if it does not exist, return success */ boolean writeData(File f, Data d) { FileOutputStream fos = null; try { fos = atomicCreateF...

2
голосов
2ответов
1329 просмотров

How to write logs to files of size 64KB in C++/VC++?

How to write logs to files of size 64KB(to allow notepad to read).Once the file has reached 64KB it should go head and create another , another ...... File names can be automatically generated. I tried the following code static int iCounter=1; CString temp; static CStdioFile f(L"c:\Log1.t...

1
голосов
2ответов
2695 просмотров

python adding gibberish when reading from a .rtf file?

I have a .rtf file that contains nothing but an integer, say 15. I wish to read this integer in through python and manipulate that integer in some way. However, it seems that python is reading in much of the metadata associated with .rtf files. Why is that? How can I avoid it? For example, t...

2
голосов
2ответов
147 просмотров

Why won't GDI let me delete large images?

My ASP.NET application has an image cropping and resizing features. This requires that the uploaded temporary image be deleted. Everything works fine, but when I try to delete an image larger than 80px by 80px I get a "File is locked by another process..." error, even though I've released all res...

3
голосов
3ответов
6437 просмотров

File.ReadAllBytes Code Refactoring

I came across this piece of code today: public static byte[] ReadContentFromFile(String filePath) { FileInfo fi = new FileInfo(filePath); long numBytes = fi.Length; byte[] buffer = null; if (numBytes > 0) { try { FileStream fs = new FileStream(f...

1
голосов
4ответов
3658 просмотров

how to check whether a file exists before creating it

I am creating an xml file. I need to check first if the file exists or not. If the file does not exist, create it and add the data cmg from a .cs file. If the file exists, don't create the file just add the data cmg from a .cs file. My code looks like this: string filename="c:\employee.xml"; X...

7
голосов
5ответов
7203 просмотров

C++ non null terminated char array outputting

I was trying to output a not null terminated char array to a file. Actual thing is, I am receiving packets and then printing their fields. Now as these fields are not null terminated, for example, a data segment which has size of 512 but may or may not be completely occupied. When I write this...

0
голосов
1ответов
1906 просмотров

Is it possible to use wildcards in the .htaccess file for mass moves?

I am reworking my website, going to be renaming a lot of directories, and need a simple way to write my .htaccess redirects for all of those pages. I am hoping for a solution that does not include a very long list of files. My .htaccess file is huge as it is.

2
голосов
4ответов
2464 просмотров

Reading in an ascii 'maze' into a 2d array

I'm writing code to read in a 7x15 block of text in a file that will represent a 'maze'. #include <iostream> #include <fstream> #include <string> #include "board.h" int main() { char charBoard[7][15]; //the array we will use to scan the maze and modify it ifstream ...

0
голосов
3ответов
2713 просмотров

fread terminating mid-read at null values. Also reading in garbage past expected data

I am reading in pieces of a binary file using a FILE object in C++. Here is the fseek and corresponding fread call: fseek(fp, startLocation, SEEK_SET); fread(data, m_sizeOfData, 1, fp); m_sizeOfData ends up being an integer greater than 400 thousand. This appears that it should read all 400 ...

1
голосов
6ответов
306 просмотров

Inserting something at a particular line in a text file using PHP

I have a file called config.php, I want it to remain exactly as is, however on Line # 4 there is a line saying: $config['url'] = '...could be anything here'; I'd like to only replace the contents of line # 4 with my own url provided for $config['ur'], is there a way to do this in PHP?

0
голосов
1ответов
299 просмотров

ASP.NET Retrieving text via System.IO.File vs WebRequest

I have a text file that I need to retrieve to populate a web page. My first instinct was to use System.IO.File to open and read the file contents. then it occured to me I could also use a web request (since the file lives on the webserver). I'm wondering which one is a better choice. I figure u...

1
голосов
3ответов
321 просмотров

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...

3
голосов
4ответов
1468 просмотров

How to append text to multiple files

I am not a programmer, but I am a researcher and I need to modify some files. I have a number of text files with *.mol extension located in c:\abc\ directory . I need to append line containing following text "M END" to each file in this list. I tried following in C# but without any result: u...

4
голосов
5ответов
2963 просмотров

std::string equivalent for data with null characters?

I'd like to read a binary file and use something like std::string that automatically resizes the buffer and such. I'm using Visual C++. What are my options?

0
голосов
1ответов
299 просмотров

zend framework: can not access file that is already there

I am trying to read and post back to the browser a file uploaded with the zend framework mechanism. The file has been uploaded correctly to the desired location and as I have checked by su www-data and after an ls and a cat, the web user can read it and modify it properly. the problem is t...

1
голосов
4ответов
1067 просмотров

De-dupe files in BASH

I have a set of, oh 8000 or so files, that I need to de-dupe. The files are essentially lists of numbers delimited by returns: nnnn nnnnn nnnn and I would like to sort and de-dupe the numbers within the files themselves. I can do this manually using sort | uniq or sort -u but I effectively wa...

1
голосов
4ответов
2154 просмотров

C file pointer read write issues

I was trying to make a simple bubblesort program. Read in numbers from a text file and compare them with the next line, sort in ascending order. Now, I've found my program is able to read from the file just fine, it's when I use any write commands (fprintf, or fputs) that everything goes wrong....

63
голосов
6ответов
43500 просмотров

Unit Testing File I/O

Reading through the existing unit testing related threads here on Stack Overflow, I couldn't find one with a clear answer about how to unit test file I/O operations. I have only recently started looking into unit testing, having been previously aware of the advantages but having difficulty gettin...

1
голосов
5ответов
1332 просмотров

File echo loop with extra final iteration

Why do I get an extra iteration (extra line printed) when this code completes? Does there need to be an extra newline at the EOF? I would prefer not having to add extra/special characters to mark the EOF. #include <iostream> #include <fstream> #include <string> using na...

1
голосов
4ответов
8619 просмотров

Is there a BinaryReader in C++ to read data written from a BinaryWriter in C#?

I've written several ints, char[]s and the such to a data file with BinaryWriter in C#. Reading the file back in (in C#) with BinaryReader, I can recreate all of the pieces of the file perfectly. However, attempting to read them back in with C++ yields some scary results. I was using fstream...

34
голосов
9ответов
76841 просмотров

File.createNewFile() thowing IOException No such file or directory

I have a method that writes to a log file. If the file exists it should append to it, if not then I want it to create a new file. if (!file.exists() && !file.createNewFile()) { System.err.println("Error with output file: " + outFile + "\nCannot create new file."); continu...

13
голосов
4ответов
14959 просмотров

Elegant way to skip first line when using python fileinput module?

Is there an elegant way of skipping first line of file when using python fileinput module? I have data file with nicely formated data but the first line is header. Using fileinput I would have to include check and discard line if the line does not seem to contain data. The problem is that it wo...

1
голосов
1ответов
244 просмотров

What is the proper method of reading and parsing data files in C++?

What is an efficient, proper way of reading in a data file with mixed characters? For example, I have a data file that contains a mixture of data loaded from other files, 32-bit integers, characters and strings. Currently, I am using an fstream object, but it gets stopped once it hits an int32 ...

1
голосов
6ответов
3909 просмотров

what is the most efficient way of reading a log file in java?

What is the most efficient(fast and safe) way of reading a log file in java? The log file continuously(almost every second) gets updated.

14
голосов
2ответов
15303 просмотров

J2ME/Blackberry - how to read/write text file?

please give me a sample code for read/write text file in blackberry application.

1
голосов
3ответов
3289 просмотров

Open Excel workbook in C#

I'm facing a strange issue when trying to open an excel sheet through a C# application. it uses something like the following while the templatePath is C:\template.xls for example. Workbook excel_workbook = this.excel.Workbooks.Open(templatePath, mMissingValue, false, mMissingValue, mMissingValue...