file-io

C# Simple File I/O

I'm trying to write a program that does this: In this exercise exam scores for a class of students is stored in a file. You are to write a program that successfully opens the file, reads in the exam scores, finds the average score, the highest score, and the lowest score, and prints these out. The average score should be printed with 2 ...

A design suggestion for changing php or general server side code through a web console

Ok so this is my situation...a web application in PHP uses a "config" file for various parameters. This config file is nothing but a php file, say config.php with a global array of the form $config['param_name'] = 'param_value'; $config['param_name2'] = 'param_value2'; Now I am currently writing an admin app that I want to use to cont...

Save Contents Of a TextBox To a File

Hello, I'm developing an application that has a TextBox. I want to write its contents to a file, but how can I do this? ...

FileSystemWatcher Priority

I am looking to monitor a folder for create events using the FileSystemWatcher in c#. The problem is that another 3rd party process is also watching that folder, I need (if possible) for my process to receive the create event before the 3rd party process. Is there a way in managed or unmanaged code that I can give my process a higher pr...

Fastest way to read a file line by line with an arbitrary number of characters in each

Ok, I'm trying to figure out which way would be faster to read a text file that I'm working with. The contents of the file look like this 1982 3923 3542 4343 2344 3453 2 334 423423 32432 23423 They're basically just an arbitrary number of int numbers and I need to read line by line. Would it be better to use getline or the insertion ...

File I/O In DrScheme

(read) takes in a string from stdin, parses it as an s-expression, and returns that expression. How do I do the exact same thing, except taking input from a file? ...

why fseek or fflush is always required between reading and writing in the read/write "+" modes.

Q: I'm trying to update a file in place, by using fopen mode "r+", reading a certain string, and writing back a modified string, but it's not working. A: Be sure to call fseek before you write, both to seek back to the beginning of the string you're trying to overwrite, and because an fseek or ff...

Working With Files

Hello, I'm needing to create a application that will read a file, that will be like this: Font = "Courier New" Size = "10" Style = "Bold" As you can see I'm going to use this to set some properties of a TextBox, but I'm going to store each thing that is inside these quotes and store they on some variables(textFont, textSize, textStyl...

File paths in Java (Linux)

I have created a Java application that loads some configurations from a file conf.properties which is placed in src/ folder. When I run this application on Windows, it works perfectly. However when I try to run it on Linux, it throws this error: java.io.FileNotFoundException: src/conf.properties (No such file or directory) ...

Is There Any Way Without File.ReadAllText?

Hello, As I love to develop file I/O applications and my new development platform is Windows Mobile. Is there any way to read all the file, without using File.ReadAllText? Because Windows Mobile don't have this function. ...

Invalid Argument When Using String Array

Hello, I'm building a program that uses a WriteAllLines generic function: private static void WriteAllLines(string file, string[] contents) { using (StreamWriter writer = new StreamWriter(file)) { foreach (string line in contents) { writer.Write(line); } } } But the problem is that when...

Value Doesn't Fall Within The Expected

Hello, I'm building a application that uses a file to configure some fonts. It's like this: Font = Verdana Size = 12 Style = Bold And my code is like this: openDialog.ShowDialog(); string file = openDialog.FileName; StreamReader reader = new StreamReader(file); while (reader.Peek() <= 0) { string line = reader.ReadLine(); st...

File.open ,open and IO.foreach in Ruby ,what is the difference?

Hi, All of the following API do the same thing: open a file and call a block for each line. Is there any preference we should use one than another? File.open("file").each_line {|line| puts line} open("file").each_line {|line| puts line} IO.foreach("file") {|line | puts line} ...

How to tell why a file deletion fails in Java?

File file = new File(path); if (!file.delete()) { throw new IOException( "Failed to delete the file because: " + getReasonForFileDeletionFailureInPlainEnglish(file)); } Is there a good implementation of getReasonForFileDeletionFailureInPlainEnglish(file) already out there? Or else I'll just have to write it myself. ...

How to efficiently process 300+ Files concurrently in scala

Hello I'm going to work on comparing around 300 binary files using Scala, bytes-by-bytes, 4MB each. However, judging from what I've already done, processing 15 files at the same time using java.BufferedInputStream tooks me around 90 sec on my machine so I don't think my solution would scale well in terms of large number of files. Ideas...

Associate a File To a Application

Hello, I'm building two programs, a text editor and a zipper, but in this two programs I want to associate a file type to they, but how can I do this? Thanks. ...

FileAssociationInfo And ProgramAssociationInfo

Hello, I'm developing a application for Windows Mobile using C#(.Net Compact Framework 3.5), but I need to associate my program with a file type. When I try to use FileAssociationInfo I'm getting this error: The type or namespace name 'FileAssociationInfo' could not be found (are you missing a using directive or an assembly reference?) ...

Get All current file names in directory and write it out in console C#

I'm writing a program that requires the ability to list all applications installed, and it will do that by listing all the uninstallers for it in a specific directory. This code isn't working, and the directory is created and there are files in the directory if (startarg.Contains("-il") == true) { //Lists all...

opening a file with fopen

I've been trying to open a file and output text, but I keep getting errors. So I thought I would start at the very beginning and just try opening the file. This is my code: #include <stdio.h> #include <stdlib.h> #define CORRECT_PARAMETERS 3 int main(void) { FILE *file; file = fopen("TestFile1.txt", "r"); if (file == NULL)...

Waiting until a file is available for reading with Win32

I'm watching a directory by calling ReadDirectoryChangesW synchronously. When a new file is available, I try to access it immediately with CreateFile with GENERIC_READ and FILE_SHARE_READ, but this gives me ERROR_SHARING_VIOLATION. The process that put the file in the watched directory does not finish writing by the time I try to read it...