file-io

PHP Case Insensitive Version of file_exists()

I'm trying to think of the fastest way to implement a case insensitive file_exists function in PHP. Is my best bet to enumerate the file in the directory and do a strtolower() to strtolower() comparison until a match is found? ...

Is it possible to read and write in file at the same time ?

Here's the scenario: ThreadA is going to read from some socket, and write data to "MyFile.txt" ThreadB is going to read "MyFile", and when it reaches the end, it will loops until new data are available in MyFile (because i don't want to re-open "MyFile.txt", and lose the time so i reach the position from where i was..). Is it possibl...

Cycling a binary file in Python - Remove from beginning add to end

Could anyone point me towards a method of cycling a binary file in Python? I have a file full of 4 byte integers basically and when the file reaches a certain size, i.e. a certain number of values have been written, I want to start removing one from the start and adding one at the end. I'm still reasonably new to Python, so just trying ...

code to loop through all workbooks in a folder VB

Hi, I have a number of excel (.xls) stored in a folder in a local drive. I need to do some process to every file in this folder. What is the code that will loop through every file open the file Do some processing and then Save & close the file move the file to another folder after processing To be more clear, I want go over every fi...

How do I write a UTF-8 encoded string to a file in windows, in C++

Hello all, I have a string that may or may not have unicode characters in it, I am trying to write that to a file on windows. Below I have posted a sample bit of code, my problem is that when I fopen and read the values back out windows, they are all being interpreted as UTF-16 characters. char* x = "Fool"; FILE* outFile = fopen( "Se...

XCode, standard C++ and ifstream file handling.

Recently, I figured out that Xcode could be used to write normal C++ programs. My problem is with the following code : #include <iostream> #include <fstream> using namespace std; int main (int argc, char *argv[]) { char operation='0'; int operand=0; //open file for reading ifstream ifile; ifile.open (argv[1]); ...

How to create a java.io.File from a ByteArrayOutputStream?

I'm reading a bunch of files from an FTP. Then I need to unzip those files and write them to a fileshare. I don't want to write the files first and then read them back and unzip them. I want to do it all in one go. Is that possible? This is my code FTPClient fileclient = new FTPClient(); .. ByteArrayOutputStream out = new ByteArrayO...

java servlet serving a file over HTTP connection

I have the following code(Server is Tomcat/Linux). // Send the local file over the current HTTP connection FileInputStream fin = new FileInputStream(sendFile); int readBlockSize; int totalBytes=0; while ((readBlockSize=fin.available())>0) { byte[] buffer = new byte[readBlockSize]; ...

Exclusive access to text file, to read and overwrite it.

Hi, I'd like to open a text file and not allow any other processes to write to it. I understand I can do this with the following FileStream: Dim fs As New FileStream(_FilePath, FileMode.Open, FileAccess.ReadWrite, FileShare.Read) Once I have access like this I need to read all of the lines (I will use a StreamReader(fs)) and then I w...

Loading a text file from AndroidTestProject

I have two projects, my main android application and another test project that runs on top of that android application. I have placed a text file in my android test project, This file contains information xml content. The xml content is what my android application will receive when I hit my server. I am using the TestCase class in my ...

Is there a way to get this C# code to automatically overwrite files?

Is there a way to get this code to automatically overwrite files? // Requires project reference to Microsoft.VisualBasic using Microsoft.VisualBasic.FileIO; class FileProgress { static void Main() { string sourcePath = @"C:\Users\public\documents\"; string destinationPath = @"C:\testFolder"; FileSystem.CopyDirect...

How to extract file name from file path name?

Hi, I need to move all files from source folder to destination folder. How can I easily extract file name from file path name? string newPath = "C:\\NewPath"; string[] filePaths = Directory.GetFiles(_configSection.ImportFilePath); foreach (string filePath in filePaths) { // extract file name and add new path File.Delete(filePath)...

copy from file while find a mark in python

hello guys i tried to do that code but it's not work :( F=open('C:\T\list.txt','r').readlines() B=open('C:\T\list2.txt','w') BB=open('C:\T\list2.txt','r').readlines() while BB.readlines() == 'John smith': B.writelines(F) so how i can told my python : go to copy from file : List1.txt to List2.txt but if you found John smith stop co...

What's the algorithm behind Robocopy?

I am curious to know what makes Robocopy (Robust File Copy) so fast and robust. Any body knows what is the API/Algo used for Robocopy? Anybody studied Robocopy? I am asking since I have to write a method (in .NET/C#) which will copy directories/files fast and without errors... The amount of data can go up to 15Gb and I cannot simply cal...

FileStream and memory usage

I've written the following program which purpose is to create a file of a give size with some random data in it. The program works fine and does what it's suppose to do. However, I don't understand why it consumes 5GB of RAM (see screenshot of my Task Manager). While I am writing the file with random data, I am not creating new objects. ...

Creating a single file from multiple notes in Outlook VBA

Currently, my VBA code creates a single file for each note. Here's some simplified sample code: Sub saveNotes() Set myNote = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderNotes) For ibi = 1 To myNote.Items.Count fname = myNote.Items(ibi).Subject myNote.Items(ibi).SaveAs "C:\Temp\" & fname & ".txt", 0 Next ...

iPhone file IO in pure c/posix style

Hi, is there a way to write files to the iphone file system using only pure c code and some posix like api? I only found some Objective-C/Cocoa stuff out there and I think that I can't just mix some Objective-C code snippet into the .c file. ...

Architecture: Where to sanitise uploaded file names?

I'm trying to change the way we handle uploaded files before storing them to disk. We have had some problems when users from non-windows operative systems upload files with characters that are illegal in windows file names. The idealist in me tells me that file names should be made legal as close to the web layer as possible. Thus we u...

FileShare.ReadWrite what additional permissions are needed?

The MSDN documentation for FileShare.ReadWrite says: FileShare.ReadWrite Allows subsequent opening of the file for reading or writing. If this flag is not specified, any request to open the file for reading or writing (by this process or another process) will fail until the file is closed. However, even if this flag i...

How do I limit a file size when writing to files in python

I am using the output streams from the io module and writing to files. I want to be able to detect when I have written 1G of data to a file and then start writing to a second file. I can't seem to figure out how to determine how much data I have written to the file. Is there something easy built in to io? Or might I have to count the by...