file-io

Is IntPtr.Zero equivalent to null?

I am trying to setup ReadFile to run asynchronously and according to MSDN, I need to set lpNumberOfBytesRead to null ("Use NULL for this parameter if this is an asynchronous operation to avoid potentially erroneous results.") For example, if I have the following: [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)]...

Whats wrong with this [reading input from a text file in Matlab]?

I have a text file (c:\input.txt) which has: 2.0 4.0 8.0 16.0 32.0 64.0 128.0 256.0 512.0 1024.0 2048.0 4096.0 8192.0 In Matlab, I want to read it as: data = [2.0 4.0 8.0 16.0 32.0 64.0 128.0 256.0 512.0 1024.0 2048.0 4096.0 8192.0] I tried this code: fid=fopen('c:\\input.txt','rb'); data = fread(fid, inf, 'float'); data but I a...

Reading php scripts from php file

I have a file named "connection.php". I want to read the contents of this file to a string. i use fopen, and read functions for reading. But when i am reding i just got only last 2-3 lines on that file. That means no php scripts canot read like echo , fuctions etc... How can i read the whole contents on that file?? ...

Combine physical path and virtual path outside ASP.NET

I want to convert a virtual file path to a physical file path in a windows service. I know what the physical path is for the virtual directory, so I have the following function that works, but feels like a fudge: public static string GetPhysicalPathFromVirtual(string rootPath, string virtualPath) { int trailingSlash = virtualPath.I...

How can I create a binary file in Perl?

For example, I want to create a file called sample.bin and put a number, like 255, so that 255 is saved in the file as little-endian, FF 00. Or 3826 to F2 0E. I tried using binmode, as the perldoc said. ...

Ant: How to execute a command for each file in directory?

Hello! I want to execute a command from an Ant buildfile, for each file in a directory. I am looking for a platform-independent solution. How do I do this? Sure, I could write a script in some scripting language, but this would add further dependencies to the project. ...

how to pen Iphone .plist file in Windows Machine?

In my Iphone application i have .plist file in which i am putting all the Input data. I will further use this data in the code: directly from .plist file. The problem is that when i am going to open the .plist file in a windows machine, it is not showing its original content. It is just showing the Binary characters or junk characters. ...

How to split file into chunks while still writing into it?

Hi, I tried to create byte array blocks from file whil the process was still using the file for writing. Actually I am storing video into file and I would like to create chunks from the same file while recording. The following method was supposed to read blocks of bytes from file: private byte[] getBytesFromFile(File file) throws IOEx...

c trimming newline character when reading input from file

Is this a safe way to trim the newline character off of a line after reading it in from a file? while ( fgets(buffer, 1024, fp) != NULL ) { buffer[strlen(buffer)-1] = '\0'; fprintf (stderr, "%s\n", buffer); } It doesn't give me any seg faults but could it cause problems down the road? Should I do something like this instead? ...

.NET File.Create , can't delete file afterwards...

Using method: System.IO.File.Create() After the file gets created, it still remains used by a process, and I can't delete it. Any idea how I can better create the file, should be a 0byte file, and then somehow close and dispose? ...

read words from line in C++

Hey everyone, I was wondering if there was a way to read all of the "words" from a line of text. the line will look like this: R,4567890,Dwyer,Barb,CSCE 423,CSCE 486 Is there a way to use the comma as a delimiter to parse this line into an array or something? ...

ASP.NET File IO Issue - System.UnauthorizedAccessException - stranger than you think

Hi, I am getting a strange issue where I seem to have read access, because I can 1. Get a list of files from a directory (Directory.GetFiles()) 2. Load an XML document using XmlDocument instance's Load() method But I can't use File.ReadAllText() to load a text file into memory. Gives me an System.UnauthorizedAccessException. I am not ...

Reading the first line of a file in Ruby

I want to read only the first line of a file using Ruby in the fastest, simplest, most idiomatic way possible. What's the best approach? (Specifically: I want to read the git commit UUID out of the REVISION file in my latest Capistrano-deployed Rails directory, and then output that to my tag. This will let me see at an http-glance what...

How to program number of your threads in Delphi

I found this on the Dr Dobbs site today at http://www.ddj.com/hpc-high-performance-computing/220300055?pgno=3 It's a nice suggestion regarding thread implmentation. What is best way of achieving this with TThread in Delphi I wonder? Thanks Brian === From Dr Dobbs ============== Make multithreading configurable! The number of threads u...

How to create directories using the C standard library (or otherwise) ?

Help appreciated. Couldn't find any mention of this in "the book" (k&r). ...

PHP: read last line from file

I've been bumping into a problem. I have a log on a Linux box in which is written the output from several running processes. This file can get really big sometimes and I need to read the last line from that file. The problem is this action will be called via an AJAX request pretty often and when the file size of that log gets over 5-6MB...

Java does not have a listDirectories/listFiles method, any native library?

Possible Duplicate: How to retrieve a list of directories QUICKLY in Java? Java does not have a listDirectories/listFiles method, in order to find out your set of directories or files, you have to iterate through each one and call isDirectory. This proves to be a huge performance problem for us in the unix platform. Is there a n...

How to read a bin file to a byte array?

I have a bin file that I need to convert to a byte array. Can anyone tell me how to do this? Here is what I have so far: File f = new File("notification.bin"); is = new FileInputStream(f); long length = f.length(); /*if (length > Integer.MAX_VALUE) { // File is too large }*/ // Create the byte array to hold the data byte[] byt...

How to determine that a file is in use before deletion?

I'm writing a windows service that might delete a file at some point. Because the service is dealing with regular file IO it's possible that a file can be in use during deletion. Currently I'm trying to delete and react later when an exception happens. Code looks something like this: try { File.Delete(file); ...

C#: How do I delete the first "X" lines of a text file?

Hello, For a project that I am doing, one of the things that I must do is delete the first X lines of a plaintext file. I'm saying X because I will need to do this routine multiple times and each time, the lines to delete will be different, but they will always start from the beginning, delete the first X and then output the results to ...