file-io

How to Read desired string from a given text file ??? using C#

Hello All, In C#, Is it possible to read the desired string from a given text file ? Sample content: aaaaaaaaaaaaaabbbbbcccccc dddddddddeeeeeeeeefffffff gggghhhhhhhhiiiijjjjjjjkk lllmmmmmmmmmmmnnnnnnnnnnn ooooooooooopppppppppppppp Now I have to read ffffff and iiiiiii and lllll and so on.... Thanks in advance... ...

atomic writing to file with Python

I am using Python to write chunks of text to files in a single operation: open(file, 'w').write(text) If the script is interrupted so a file write does not complete I want to have no file rather than a partially complete file. Can this be done? ...

matlab quickie: test if text file is empty

Simple question: I am opening a file in matlab 7.x, and I want to test if it is empty before reading it. What's the best way to do this? ...

Reading a whole file on a network drive the fast way (Windows, C/C++, C#, ...)

Lately I've been having problems reading big files on a network drive and I just can't pinpoint what I may be doing wrong. I tried both in C++ (Unmanaged) and in C# and had about the same performances on both...which were somewhat abysmal. Sometimes it will read at 4 KB/s a file on the network, but if this file is located on the local H...

C++ EOF Getline Error

I was using the form used in one of the related questions. Only problem is that i keep getting right at the end of the file. The file is an fstream and the str is a string. Unhandled exception Microsoft C++ exception: std::ios_base::failure while (getline(file, str)) { } if (cin.bad()) { // IO error } else if (!cin.eof()) ...

16-Bits BMP Validation

I'm developing a script using VBScript and I need to validate the input file as a 16-Bits BMP. At the time my script is like this: Const OverwriteExisting = TRUE Set objFSO = CreateObject("Scripting.FileSystemObject") objFSO.CopyFile "C:\16bmp.bmp" , "D:\test.bmp", OverwriteExisting But How can I validate the input file as a 16-Bits...

How to convert InputStream to FileInputStream

I have this line in my program : InputStream Resource_InputStream=this.getClass().getClassLoader().getResourceAsStream("Resource_Name"); But how can I get FileInputStream from it [Resource_InputStream] ? ...

Ruby: How to determine if file being read is binary or text

Hi, I am writing a program in Ruby which will search for strings in text files within a directory - similar to Grep. I don't want it to attempt to search in binary files but I can't find a way in Ruby to determine whether a file is binary or text. The program needs to work on both Windows and Linux. If anyone could point me in the ri...

Using a regular expression in perl to list variables from another perl script

My thoughts on how to grab all scalers and arrays out of perl file went along the lines of: open (InFile, "SomeScript.pl"); @InArray = <InFile>; @OutArray = {}; close (InFile); $ArrayCount = @InArray; open (OutFile, ">outfile.txt"); for ($x=0; $x<=$ArrayCount; $x++){ $Testline = @InArray[$x]; if($Testline =~ m/((@|\$)[A-Z]+)/i){ $O...

Need to write files to disk, how can I reference the folder in a web application?

In a web application, that may be installed anywhere on the filesystem, I need to figure out the path to the root of the installation folder. I want to write xml files to the directory: c:/installation/path/web_app/files/ Is this possible or do I have to store this path in the web.config? ...

fgets from stdin problems [C]

I'm writing a program that works with files. I need to be able to input data as structures, and eventually read it out. The problem i have at the moment is with this code: typedef struct { char* name; ..... }employeeRecord; employeeRecord record; char name[50]; if(choice == 1) { /*Name*/ printf("\nEnter the...

PHP: reading a text file and executing SQL statements to MySQL

I want to create a form in PHP that will load a .sql file, read its contents, and execute those statements against a MySQL database. Currently using function get_file_contents but it's not working. What can I do? ...

Difference between 'File.Open()' and 'new FIleStream()'

What's the difference, if any? ...

Does HTML5 allow you to interact with local client files from within a browser

I've seen some posts regarding access to files on a client machine by a webpage, namely this question. I'm trying to hop on the "continuously update in the cloud" paradigm for some algorithms I am writing so my users can access the latest versions by simply accessing the webpage. This requires that the program/webpage can start with a ...

VBA - Read file byte by byte on system with Asian locale

Hi, I am trying to convert a file from binary to text, by simply replacing each character with the hexadecimal code. For example, character 'c' will be replaced by '63'. I have a code which is working fine in normal systems, but it breaks down in the PC where I need to use it as it has default locale set to Chinese. I am using the foll...

c++ binary read/write problem

I've looked at binary reading and writing objects in c++ but are having some problems. It "works" but in addidion i get a huge output of errors/"info". What i've done is Person p2; std::fstream file; file.open( filename.c_str(), std::ios::in | std::ios::out | std::ios::binary ); file.seekg(0, std::ios::beg ); file.read ( (char*)&p2, s...

Java- FileWriter/BufferedWriter - appending to end of a text file?

I've done this before once, I'm trying to replicate what I did so far and this is what I've got: try { BufferedWriter writer = new BufferedWriter(new FileWriter("file.P", true)); System.out.println("entered"); if (!(newUserName.isEmpty()) || (newUserPass.isEmpty())){ writer.newLine(); ...

c#: how to read parts of a file? (DICOM)

I would like to read a DICOM file in C#. I don't want to do anything fancy, I just for now would like to know how to read in the elements, but first I would actually like to know how to read the header to see if is a valid DICOM file. It consists of Binary Data Elements. The first 128 bytes are unused (set to zero), followed by the st...

Split HTML files

How would I split a HTML formatted file into several HTML files (complete with with HTML, HEAD and BODY tags) with PHP? I would have a placeholder tag (something like <div class='placeholder'></div> ) for all the places I want to cut. Thanks. ...

Copying Files Using NSBasic/CE 7.0

I'm using NSBasic/CE 7.0 and I'm needing to copy a file, but I don't know how to copy using this program, but at the time I already have this: AddObject "cecomdlg.commondialog.1", "ComSvDlg", 0, 0, 0, 0 Sub saveDialog() ComSvDlg.CancelError = 0 ComSvDlg.DialogTitle = "Copy" ComSvDlg.Filter = "All Files|*.*" ComSvDlg.ShowSave ...