Questions tagged [file-io]

File I/O is input/output that involves the file system. This could include performing operations on directories and files, such as creation and deletion, reading files, and writing output to files.

For an introduction on File I/O in C, see C Programming / File I/O on Wikibooks.

21104 questions
9
votes
1 answer

UNC path pointing to local directory much slower than local access

Some code I'm working with occasionally needs to refer to long UNC paths (e.g. \\?\UNC\MachineName\Path), but we've discovered that no matter where the directory is located, even on the same machine, it's much slower when accessing through the UNC…
Chris Doggett
  • 19,959
  • 4
  • 61
  • 86
9
votes
4 answers

Basics - reading/writing remote files using Java

I started with requirement of reading and writing files in from/in a directory on a remote Ubuntu machine. First, I wrote a Java program that could read,write files from a shared folder on a remote Windows machine i.e on a LAN. Here, something like…
Kaliyug Antagonist
  • 3,512
  • 9
  • 51
  • 103
9
votes
1 answer

Access is denied when trying to CreateFileAsync in InstalledLocation StorageFolder?

I got Access is denied when trying to CreateFileAsync in InstalledLocation StorageFolder StorageFolder storageFolder = Windows.ApplicationModel.Package.Current.InstalledLocation; StorageFile file = await storageFolder.CreateFileAsync("fileNmae",…
isa
  • 1,055
  • 16
  • 26
9
votes
3 answers

Python: Traceback codecs.charmap_decode(input,self.errors,decoding_table)[0]

Following is sample code, aim is just to merges text files from give folder and it's sub folder. i am getting Traceback occasionally so not sure where to look. also need some help to enhance the code to prevent blank line being merge & to display no…
user1582596
  • 503
  • 2
  • 5
  • 16
9
votes
5 answers

C# WriteFile() Stops Writing at Sector 242 on USB Drives

I wrote the below code to write 0xFF to all bytes on my USB storeage device. For some reason the WriteFile() calls begin to error out at sector 242. I have done this on two separate USB storage devices and then examined the devices in a hex…
Brandon Stout
  • 359
  • 10
  • 22
9
votes
2 answers

DirectoryInfo.GetFiles slow when using SearchOption.AllDirectories

I am searching a moderate number (~500) of folders for a large number (~200,000) of files from a .NET application. I hoped to use DirectoryInfo.GetFiles, passing in SearchOption.AllDirectories. However this approach seems to be a lot slower than…
Richard Ev
  • 52,939
  • 59
  • 191
  • 278
9
votes
3 answers

Reading a large file using C (greater than 4GB) using read function, causing problems

I have to write C code for reading large files. The code is below: int read_from_file_open(char *filename,long size) { long read1=0; int result=1; int fd; int check=0; long *buffer=(long*) malloc(size * sizeof(int)); fd =…
srijeet
  • 91
  • 1
  • 1
  • 2
9
votes
1 answer

Seeking in large files with ifstream

I'm implementing a program in C++ using ifstream that must seek in large files (~1TB). However, this fails after reading 2GB. Is there a way to get file positions, even for large files? I compile for a 32-bit windows machine. std::ifstream…
Patrik
  • 2,695
  • 1
  • 21
  • 36
9
votes
5 answers

how to get url html contents to string in java

I have a html file stored on the server. I have the URL path something like this: I want to read the contents of this html file which would contain tags, from the url i.e. the source code of the…
Peyush Goel
  • 383
  • 2
  • 3
  • 13
9
votes
6 answers

How to create a file and its parent directories in one method call?

I want to create a file that is in specific directory. For example: C:\x\y\z\aTextFile.txt For this operation, I have to create the directory to create file. Directory.CreateDirectory(@"C:\x\y\z\"); File.Create(@"C:\x\y\z\aTextFile.txt"); But I…
ibrahimyilmaz
  • 18,331
  • 13
  • 61
  • 80
9
votes
4 answers

Java File Transfer API

I need to transfer files to my web server for processing and I'd like to do it in a generic way if possible. I need to be able to transfer files from the following protocols at a minimum (with more to follow eventually): HTTP FTP SCP I'd really…
Tim Bornholtz
  • 103
  • 1
  • 5
9
votes
2 answers

How do you write zero copy in java? What are the main differences

I was reading about how you can use the java nio library to take advantage of file transfer/buffering at the O/S level which is called 'zero copy'. What are the differences in how you create/write to files then? Are there any drawbacks to using…
loyalflow
  • 14,275
  • 27
  • 107
  • 168
9
votes
2 answers

Dealing with a very large number of files

I am currently working on a research project which involves indexing a large number of files (240k); they are mostly html, xml, doc, xls, zip, rar, pdf, and text with filesizes ranging from a few KB to more than 100 MB. With all the zip and rar…
Martijn
  • 521
  • 1
  • 8
  • 17
9
votes
2 answers

How to read line by line from a text area

I have figured out how to read in line by line and display the contents of a text document line by line into a jtextarea and I have figured out how to write out line by line from an array of strings to the text document. I am just having a hard time…
Charlie
  • 1,308
  • 5
  • 14
  • 24
9
votes
7 answers

Tried and true simple file copying code in C?

This looks like a simple question, but I didn't find anything similar here. Since there is no file copy function in C, we have to implement file copying ourselves, but I don't like reinventing the wheel even for trivial stuff like that, so I'd like…
Eugene Bujak
  • 1,591
  • 2
  • 14
  • 14