file-io

Join Records on Multiple Line File based on Criteria

Hello, I am trying to write a python script that takes record data like this 6xxxxxxxx 7xxxxxxxx 6xxxxxxxx 7xxxxxxxx 7xxxxxxxx 6xxxxxxxx 6xxxxxxxx 6xxxxxxxx 7xxxxxxxx 7xxxxxxxx 7xxxxxxxx and performs the following logic newline = "" read in a record if the record starts with a 6 and newline = '' newline = record if the...

How to open a file and put its contents In a TextField?

I'm trying to learn how to open a file, and put its contents in a TextField, using a Common Dialog, only a command dialog in Visual Basic 6. I need this using a only a common dialog, because I'm trying to do the same application in eVB, and eVB does not support things like these, that makes the VB6 development more simple: Dim objFSO A...

c++ std::fstream behaviour on MacOS

On MacOS with gcc4.2 should the following code create a new file if none exists? #include <fstream> void test () { std::fstream file ("myfile.txt", std::ios::in | std::ios::out); } By my logic it should, either open up an existing file for read/writing or create a new empty file for read/writing. But the behaviour I get is that i...

Newlines in string not writing out to file

I'm trying to write a program that manipulates unicode strings read in from a file. I thought of two approaches - one where I read the whole file containing newlines in, perform a couple regex substitutions, and write it back out to another file; the other where I read in the file line by line and match individual lines and substitute o...

Read Permission problem on .NET Embedded Resource - Access DB file & SSIS

Hello. I am currently creating dynamic SSIS packages that import/export and access data between a SQL Server and several Access DB files. (Jet files if you want to get technical.) Anyways, everything is successful during testing, as long as my SSIS packages have hard-coded connection strings to the Access file. This is great and works f...

How to read windows .exe file version?

I need to parse the file version and product version from windows exe and msi files. Could you point me to the file specification or the library (preferably in Java) that does that? UPDATE: It turns out I cannot use winapi, as the code needs to run on linux as well... ...

ifstream.read() vs. ifstream.readsome() in MSVC++7.1

Hi, I just took some older code of a file reader that had been developed under Linux and tried to use that very same code in my Windows project compiled with MSVC++7.1. The code compiled without any problems, but the file seemed to be empty according to the file reader on Windows. I tracked the problem down to ifstream.readsome() that ...

Java output a file to the screen

I know this is a little broad, but here's the situation: I am using JSP and Java. I have a file located on my server. I would like to add a link to the screen that, when clicked, would open the file for the user to view. The file can either appear in a window in the web browser, or pop up the program needed to open the file (similar ...

Which flags to open a file the way Notepad.exe does?

Hi all. I'm writing a C# app to read a file that another application holds open. As some of you may guess, all I get is IOExceptions because "the file is being used by another process". I've tried tweaking File.Open() a little; this is my current try: FileStream fsIn = File.Open(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);...

File corruption detection and error handling

I'm a newbie C++ developer and I'm working on an application which needs to write out a log file every so often, and we've noticed that the log file has been corrupted a few times when running the app. The main scenarios seems to be when the program is shutting down, or crashes, but I'm concerned that this isn't the only time that someth...

Error When Reading a Sequencial File In C++

Hello, I'm having some problems when i try to compile my sample C++ project, i'm trying to read a sequencial file, but when i compile i got some errors, here is the code: // ReadClientFile.cpp // Lendo e imprimindo um arquivo sequêncial. #include <iostream> using std::cerr; using std::cout; using std::endl; using std::fixed; using std...

Is FileInfo.CopyTo / File.Copy guaranteed to succeed?

By "guaranteed to succeed" I mean: If no Exception is thrown on the call to CopyTo, can I safely assume that the file was copied perfectly, or would it be reasonable to validate the copy (such as with a checksum)? This of course assumes that the integrity of the file is mission-critical. ...

C++ unicode file io

I need a file io library that can give my program a utf-16 (little endian) interface, but can handle files in other encodings, mainly ascii(input only), utf-8, utf-16, utf-32/ucs4 including both little and big endian byte orders. Having looked around the only library I found was the ICU ustdio.h library. I did try it however I coudlnt ...

cleaning up when using exceptions and files in python

Hello all, I'm learning python for a couple of days now and am struggling with its 'spirit'. I'm comming from the C/C++/Java/Perl school and I understand that python is not C (at all) that's why I'm trying to understand the spirit to get the most out of it (and so far it's hard)... My question is especially focused on exception handlin...

Delete a Line from a file in C Language

Hey, I want to delete certain lines in a file and insert certain lines in the same file based on whether certain parts of the line match a specified string. Is there a way of doing this without using a temporary file to copy the contents to and so on? Thanks Gitmo ...

StreamWriter - Not appending to created file

I am using the StreamWriter object to write to either a file that is created by the constructor or already exists. If the file exists then it appends data. If not, then it should create a file and then also append data. The problem is that when the file needs to be created, the StreamWriter constructor creates the file but does not write...

Python write to line flow

Hi, Part of my script is taking values and putting them to a text file delimited by tabs. So I have this: for linesplit in fileList: for i in range (0, len(linesplit)): t.write (linesplit[i]+'\t') I get as an output in the file what I expect in the first line but in the following lines they all start with a \t in them, lik...

Is file append atomic in UNIX?

In general, what can we take for granted when we append to a file in UNIX from multiple processes? Is it possible to lose data (one process overwriting the other's changes)? Is it possible for data to get mangled? (For example, each process is appending one line per append to a log file, is it possible that two lines get mangled?) If...

Load binary file using fstream

I'm trying to load binary file using fstream in the following way: #include <iostream> #include <fstream> #include <iterator> #include <vector> using namespace std; int main() { basic_fstream<uint32_t> file( "somefile.dat", ios::in|ios::binary ); vector<uint32_t> buffer; buffer.assign( istream_iterator<uint32_t, uint32_t>...

How can I get a block of memory from a function and write it to a file?

I want to write the data "somebytes" that I get from a function called NextUnit() to a file named "output.txt", but the code that I wrote does not work. When I open the file, it does not look like my "somebytes". Here is the code: #include <stdio.h> #include <string.h> char* NextUnit() { char Unit[256]; strcpy(Unit,"somebytes")...