Click here to Skip to main content
15,889,704 members
Everything / IO

IO

IO

Great Reads

by honey the codewitch
BinaryReader needs a better way to read strings and types. Here's a quick and dirty fix
by Alexander Eremeev
The Windows kernel-hacking library and development framework written on C++17
by Bruno van Dooren
How to implement named pipe server for communicating with client apps
by V.
Convert FITS file to known image formats and use those images for a "zooming" functionality (image transparency)

Latest Articles

by Michael Sydney Balloni
See how Rust stacks up against C-ish, C++, and C#
by Bruno van Dooren
How to implement named pipe server for communicating with client apps
by Bruno van Dooren
How to implement named pipe server for communicating with client apps
by honey the codewitch
Run your IoT display driver independent of the bus it uses, whether I2C, SPI or parallel

All Articles

Sort by Updated

IO 

5 Jan 2023 by Michael Sydney Balloni
See how Rust stacks up against C-ish, C++, and C#
22 Dec 2022 by Bruno van Dooren
How to implement named pipe server for communicating with client apps
9 Dec 2022 by Bruno van Dooren
How to implement named pipe server for communicating with client apps
18 Feb 2022 by honey the codewitch
Run your IoT display driver independent of the bus it uses, whether I2C, SPI or parallel
7 Jun 2021 by Member 15170612
Hello, I have a question, I would like to like the WPF application saves time similar to the one in the rankings. Time and number of attempts is not a problem to list but the problem occurs when I want to sort it in a text file. EDIT:I'll start...
27 May 2021 by Richard MacCutchan
You have raised this question a number of times and you still appear to be struggling. Think carefully about what you are trying to do, and the order in which you do it. 1. Call the Read method to read the records from the input file. 2. Any...
26 May 2021 by OriginalGriff
The error message says it all: the file you are trying to read is in use. When you open a file for writing, the stream acquires an "exclusive lock" on the file to prevent the contents changing while it is being read and potentially invalidating...
6 May 2021 by Patrick Skelton
I have the following code: DirectoryInfo directoryInfo = new DirectoryInfo( path ); IEnumerable files = directoryInfo.EnumerateFiles( "*.*", SearchOption.TopDirectoryOnly ); foreach( FileInfo file in files ) { // Do something......
6 May 2021 by Richard MacCutchan
See DirectoryInfo.EnumerateFiles Method (System.IO) | Microsoft Docs[^]. But what you are asking is for the system to EnumerateFiles. I think you should be using DirectoryInfo.EnumerateDirectories Method (System.IO) | Microsoft Docs[^].
24 Apr 2021 by CPallini
Your for loop overruns the number of the quiz proposed questions. I've fixed that (and other bugs, adding remarks on modified lines of code). Try (Please note, using Java facilities, there are far better ways to write such a code). import...
24 Apr 2021 by Gray Kim
import java.io.*; import java.util.*; public class GameGuess{ int x; int ctr; public static void main(String [] args){ new GameGuess(); } public GameGuess(){ GameGuess1(); } public void GameGuess1(){ Scanner con = new...
24 Apr 2021 by OriginalGriff
We have no idea what you are entering, so we can't run it under the same conditions you can. That makes working out what went wrong - and you don't really tell us what you have noticed - pretty difficult. So, it's going to be up to you....
23 Apr 2021 by honey the codewitch
BinaryReader needs a better way to read strings and types. Here's a quick and dirty fix
23 Jul 2020 by honey the codewitch
Add progress reporting to your downloading or copying using this code
19 Mar 2020 by honey the codewitch
BinaryReader and BinaryWriter can be used to parse or write binary files more easily and in a portable manner
2 Feb 2020 by honey the codewitch
Add UTF-32 support and easy foreach streaming to your apps
17 Jan 2020 by Patrice T
Quote: How java bytestream works? In a stream, a byte is the smallest chunk of data you can handle because it is how computer works. You can consider that a byte is like a digit (for computer), just like for us, a digit is 0-9 for us. A bytestream have no idea of the meaning of bytes or their...
17 Jan 2020 by 49R
How raw data is divided into bytes. As present audio contains 32bit(2^32 tones) it ranges from 2^0 - 2^32. ex -> 6710497.. (Considering decimal) how is it divided to 67 104 97 Does FileInputStream has a method to check like if(671>256){send 67 , next append 1} What I have tried: ...
17 Jan 2020 by Richard MacCutchan
Any file, or data, is just a stream of bits. In general it is convenient to handle the stream as a collection 8-bit bytes. However the bytes are often grouped together to make different types of information (int, double, string etc.). The key is that you need to know the structure of the data in...
23 Jan 2019 by Ray K
Extending BinaryReader/Writer to support a different byte order, string and date formats, and advanced navigation in binary files
13 Dec 2018 by HS_C_Student
It's pretty common that I will use fgets() in a loop to iterate through the lines of a file and process them. Normally it works well but in some cases it sucks. Example 1: If you need to know information about the next line(s) or previous line(s) to decide how to process the current line. ...
13 Dec 2018 by CPallini
Quote: Example 1: If you need to know information about the next line(s) or previous line(s) to decide how to process the current line. Example 2: The current line indicates you have read too far and you must send it to a different context of your parser. Both of such problems are usually...
13 Dec 2018 by KarstenK
When it is the work of the app to parse the complete file it should be no problem. Test it. At best you use some standard containers like int this file reading example code.
13 Dec 2018 by Mohibur Rashid
How about create index? In this case, you will have to read the file twice, but, you will have complete knowledge of your data set. You will create indexes by reading each character and seeking new line, when you hit the newline register it in memory, as array or as linked list. Using this you...
1 Nov 2018 by Alexander Eremeev
The Windows kernel-hacking library and development framework written on C++17
28 May 2018 by Marco Bertschi
The presented code snippet compares two given files using the IEqualityComparer.
9 May 2018 by Richard MacCutchan
while((l = br.readLine()) != null){ The first time this is called it reads that line into variable l, which you then display. The next time it is called, the end of file is reached, so readLine returns null, and the program terminates. You need to do some more processing each time you receive...
9 May 2018 by Member 13819453
I am using the above code to print the lines of a file. The problem is the line only appears for a millisecond. My file only contains a single line of length 70,000 and I want to split it on some substring and then write it to a different file with multiple lines as an output. I also tried...
5 Apr 2018 by David Crow
I suspect you want something like: InputStream stream = manager.open("firmware/" + file);
5 Apr 2018 by Samira Radwan
Hi all, In my app, I have added a new directory to assets. This directory has one binary (.bin)file. I'm trying to read this file using InputStream with no success. I can see the file name I even can compare the name to an existing string, but I can't open it. Please advise. What I have...
4 Apr 2018 by mygearstationcom
The error went away after modifying my code as follow: var configFile = System.IO.File.Create(@"config\config.txt"); configFile.Close(); string defaultText = ("IP Address: 012.345.678.901\r\nDevice Port: 1111\r\nLog Directory: Saved\\\r\nConfig Directory: config\\\r\nEnter Modules here.\nEnter...
4 Apr 2018 by mygearstationcom
I have a main form that opens a child form. I have a routine in the MainForm.cs to create 2 subdirectories and 1 text file. In the declaration of MainForm(), I added code to run my function "createSSMonitorSubDirectories();" void createSSMonitorSubDirectories() { if...
3 Apr 2018 by Pete O'Hanlon
This error is telling you that you are accessing an index that doesn't exist. Remember that arrays in C# start at 0 so if you wanted the 4th line, you would use 3 as the index number.
1 Apr 2018 by apb007
Hi there, I am currently trying to make a sort of io version of call of duty zombies and dying light. So far it is coming along nicely, until i hit this snag. I would like to make 2 modes: 1) an open world where quests can be completed *kinda like dying light ish* 2) a survival map based thing...
21 Feb 2018 by Adi Eduard
This article describes how to get a file's encoding with C#
16 Feb 2018 by Suren97
i need to save data in list which i input in console.I have 3 function`Show(),Add(),Delete(). When i input 1 it must show me my data's list,when i input 2 it must ask me "Enter new user's data with comma",for example` John,25,then it must be saved in my list, that's to say when i input 1 it must...
16 Feb 2018 by OriginalGriff
Is there any point in asking questions, if you are just going to ignore everything we tell you? How to add data in list to .txt file with switch-case[^] Certainly, there appears to be little point in answering them...
15 Feb 2018 by Suren97
i have Controller and Person classes,i need to add data in my list,All data that is added to the Console must be stored in a .txt file.That is, if the user inputs 1 to see the datas, it must be read from the file then displayed, when the user inputs 2 to add new data,it must be read from the...
15 Feb 2018 by Suren97
public void Add() { const string path = "C:/Users/User/Desktop/mardik.txt"; FileStream fs = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite); BinaryFormatter bf = new BinaryFormatter(); List all = bf.Deserialize(fs)...
14 Feb 2018 by OriginalGriff
Couple of things here: 1) Don't hardcode paths, use a config file instead - and if you can't work that out, then use a const value so you only have to change it in one place. 2) If you open a file or stream, you are responsible for closing and Disposing of it: none of your code does that, which...
13 Feb 2018 by Maciej Los
PLease, read my comment to the question. You have to Split[^] string on spaces, for example: string address = "Please write any Sentence"; string filter = "any"; int counter = address.Split(new string[]{" "}, StringSplitOptions.RemoveEmptyEntries).Count(x=>x==filter); Console.WriteLine("{0}",...
12 Feb 2018 by Suren97
in txt file i have a sentence: Please write any Sentence. i must create function which has 2 parameter` first file address,the second is any word. This function must return how many times did encounter the word in the sentence. For example if i will call it in main like this`...
5 Oct 2017 by Richard MacCutchan
Don't use simple arrays unless you are 100% certain how large to make them. Use one of the Collection classes as described in Trail: Collections (The Java™ Tutorials)[^].
18 Feb 2017 by Brady Kelly
Just recently my PC's performance has become dismal, I even got about 10 'pauses' in the editor while typing these two sentences. Now if I used Process Explorer, I can sort by CPU, memory, and IO, descending, so the culprits are always visible at the top of the table.The problem with that is...
18 Feb 2017 by Mehdi Gholam
You shouldn't get "pauses" on Windows 10 since the scheduler is pretty good, however:1) Pauses could indicate cpu heat problems, so check your system's fans and clean and lubricate them (WD40 is excellent).2) Disconnect from the internet and see if you still have problems.3) Update your...
7 Dec 2016 by Codes DeCodes
I have generated .DAT file and stored it in Server temp folder. Now When user clicks on Download button, the file is to be downloaded into their system. Before downloading a file, I want the browser to ask for a location in client's system like the way it happens when user downloads file in...
7 Dec 2016 by OriginalGriff
You can't - it depends on the browser. Chrome for example always stores files in it's "downloads" folder, while some versions of IE brought up a "save" dialog by default (though this could be overridden).You - as the server - have no control over what the client browser does with a file -...
17 Aug 2016 by MCSIDevelopers
What I want to do is not get the information about the file but I want to read the bits and also be able to locate bits positions within the frame header. The header is 32 bits (4 bytes) of which is what I want to get back or displayed as a message.I want to read it, edit it. The bit i want...
17 Aug 2016 by Paw Jershauge
You can use FileStream for that FileStream.ReadByte Method (System.IO)[^]
8 Apr 2016 by V.
Convert FITS file to known image formats and use those images for a "zooming" functionality (image transparency)
28 Dec 2015 by danah gaz
A lightweight, high performance, easy to use asynchronous stream copy method using IOCP with progress, throughput tracking, and no explicit thread creation.
18 Dec 2015 by dynamichael
Use extension methods, Encoding, and BitConverter to read and write native types on an IO.Stream object
7 Dec 2015 by JarmoP
If the file is in a network folder, and the network connection to that folder breaks, FileStream open may freeze. The only solution is to put it in a new thread and kill that thread after a timeout, if needed.
6 Dec 2015 by VISWESWARAN1998
Your code is working fine.Let me explain what is happening in your code.first you have initialized the employee name = null , his salary and age =0 and made this to print in a .txt file.So the ".txt" file containsnull00 and you have asked the user to enter the data which is not...
4 Dec 2015 by Richard MacCutchan
Try and think about this in logical steps. 1. Get the information from the user.2. Validate each input to make sure it is an acceptable value.Note: you may prefer to validate each item as they are input, rather than getting the inputs and then validating them all together. This will depend...
4 Dec 2015 by Member 12186188
Hi i want to write a program that asks the user for various bits of data about an employee - for example their name, job title, age and salary. I want the program to validate that the age and salary are of the correct data types (i.e. integer and double respectively) and once all data has been...
16 Oct 2015 by Am Gayathri
How to fix 'Access to the path 'D:\Fol_x\' is denied. error while try to download file using C# code.Am trying to download code using C#. But am getting error,'Access to the path 'D:\Fol_x\' is denied. Sounds like error is simple but i couldn't i tried all the solutions which i got from...
22 Sep 2015 by Member 11947599
how to import data from text file to viewtable JAVAFX ?!this is my code i want to read from a text file in this orderclassNAME >> WMC >> DIT >> NOC >> CBO >>RFC >> LCOM >>Ca >> Ce ;text file to be inputted to viewtable:classNAME1 13 2 0 14 74 34 2 9classNAME2 3 1 0 3 18 0 2...
9 Sep 2015 by Sergey Alexandrovich Kryukov
This is a wrong, totally wrong question, as nearly all questions about "difference". In this particular case, this is the same as asking "what is the difference between penguin and bird?" Penguin is a bird, and FileStream is a...
9 Sep 2015 by ZurdoDev
See the documentation:Stream: https://msdn.microsoft.com/en-us/library/system.io.stream(v=vs.110).aspx[^]FileStream: https://msdn.microsoft.com/en-us/library/system.io.filestream(v=vs.110).aspx[^]FileStream is clearly more specific for files and Stream is the base class for FileStream.
9 Sep 2015 by Arsalan Memon
What's the actual difference in stream and filestream. i mention two instances below please explain what's the difference in below two lines. both are doing same work but i want to understand actual difference?// Stream s = new FileStream(filename, FileMode.Create);// FileStream fs =...
28 Jul 2015 by OriginalGriff
For starters, don't store files you are going to pass to a word processor in your application folder.In production, the app folder is part of "Program files" which is restricted access (and generally read only) to prevent virus activity, and that may be causing some of your...
27 Jul 2015 by Akbar Giffary
Case ("3. Surat Tugas")Dim path As String = System.IO.Path.GetDirectoryName(Application.ExecutablePath) & "\LETTER\SURAT TUGAS.docx\"System.Diagnostics.Process.Start("explorer.exe", path)hi all, this is code what i've done before, it's works fine if the program installed on my local...
3 Jul 2015 by Shivachalappa Gotur
Detecting USB Modem Device using C#.NET
17 Jun 2015 by Maciej Los
Have a look here: List.ToArray Method[^]
17 Jun 2015 by Thanuj Kumara AS
As per my understanding you wants to convert List to List of arrayIn that case you can follow the below two waysvar lst = new List();1. using LINQList lstObj = lst.Select((x) => x.ItemArray).ToList();2. using foreachvar lstobj = new List(); ...
17 Jun 2015 by Member 11736644
I am trying to read a specific row of data into an array. I know how to get my excel file to read but i do not know how to get a specific row into an array....Please help me understand how to declare a dynamic array! I am currently trying to use a List but I am struggling to convert it to an...
27 Mar 2015 by Mario Z
If I understood you correctly you want to retrieve from 1 till end, from 2 till end or from 3 till end.I don't know why but I would expect that you want from 1 to 2, from 2 to 3 or from 3 to end.Nevertheless the simplest way how you can do this is to just read each line until you find your...
26 Mar 2015 by Manidas Payyoli
Here my needs.1hjgdfghjfgfsgfggfgegtegtghtreghrewthweghretgend2hjgdfghjfgfsgfggfgegtegtghtreghrewthweghretgend3hjgdfghjfgfsgfggfgegtegtghtreghrewthweghretgendAssume under this number large amount od data.I have 3 button named 1,2,3...
16 Feb 2015 by DavidGeirola
hi i'm david and i'm new in this site, i'm here because i have a problem with my solution of Client-Server communication.I have created 3 classes 'STransferMessage', 'SServer' and 'SClient'.SServer and SClient extend STransferMessage, i thought it might be the best solution because more...
9 Feb 2015 by Bhis
Various ways to sort list and compare results
26 Nov 2014 by Praveen Raghuvanshi
There was a change in requirement and I am not using the MediaElement. I am using NAudio library to play the media files as the requirement is to play media files through ASIO driver.However, I tried to code the above issue with NAudio and it seems to be working.Please have a look at the...
21 Nov 2014 by Peter Leow
Refer: 1. c retrieving total line numbers in a file[^]2. use exit(0) to exit a program, need to include #include
21 Nov 2014 by GeorgeGkas
How can I write a code in C to check in my file contains only 3 lines of text?Eg9820 sads88182c 9 298 288812cec 9 2 88 828 If there are less or more than 3 lines writen in my txt file called test.txt then the program will return an error message and will exit.
17 Nov 2014 by GeorgeGkas
Problem solved! .........................
17 Nov 2014 by den2k88
while ( fscanf ( fp, "%d", &value) == 1) // read one integer { o++; // this loop will continue until EOF or non-integer input }now you're at EOF if ( o > t_size) // If the second line of the file...
17 Nov 2014 by den2k88
The thing I see is that you're not closing the file after having it scanned the first time. So what happens?The first time you cycle through the file you go right until the END OF FILE, and the internal read pointer of the FILE structure points there. Then you try to read other t_size number...
10 Oct 2014 by Sergey Alexandrovich Kryukov
I would define UI thread is the thread where Application.Run is called. This is different from the definition of Solution 1, which is almost correct.I can explain the difference. It is possible to have two (or more) different threads, and run different UI on different thread. Those UI will...
10 Oct 2014 by Mehdi Gholam
Main thread or UI thread is the thread that the OS calls into to start your program.Background threads are things you start to do other stuff in parallel.A thread can be IO bound or CPU bound depending on what it is doing.
10 Oct 2014 by zhshqzyc
Is UI thread same as Background thread? My application is a console or windows service. I don't have a UI interface, so all processes are Background threads?Also is UI thread a I/O bound or CPU bound?
29 Sep 2014 by BillWoodruff
Re the issue asked about in the title of the question:1. Assumes the delimiter character is a comma.2. illustrates some elementary error-checking and reporting, use of 'throw, etc. but, by no means thoroughly checks the file being read for correctness.private Dictionary...
28 Sep 2014 by Roberta Mafessoni
Hi,I find it a little strange to use text files to store data that is serializable.Why don't you use XML files for example and take advantage of the OO capabilities of .Net classes.I believe it will be more convenient in your situation to use it. Anyways for sorting purposes I found...
28 Sep 2014 by LLLLGGGG
Hi,You can read the file in a string array with File.ReadAllLines(yourfilenamehere);.Then create a class which encapsulates a player. Create two fields into it: name (string) and points (int or float or whatever numeric type you want).Make the class implements IComparableYou will now...
28 Sep 2014 by Andreas Spalenski
You can use the TextReader TextWriter classes instead of StreamReader/Writer.
28 Sep 2014 by kmllev
I'm trying to create a leaderboard, but here's what I have so far and I'm a bit stuck.class utilizeLeaderboard { string mode; bool gameover; string playername; int playerscore; StreamReader sreader; StreamWriter swriter; ...
28 Sep 2014 by ashok rathod
1. You can use Dictionary for storing user score with their name as keys and scores as values. For Storing operation check below link or try googling for sorting operation on dictionary object.http://www.dotnetperls.com/sort-dictionary[title="New Window">^]
13 Aug 2014 by MonsterMMORPG
Ok there are 2 ways of writing text to a file in multi threaded systemWhich one is better than otherFirst case : having a static object to lock streamwriter and do operationsSecond case having TextWriter twWaitingToBeFetched; twWaitingToBeFetched =...
21 Jul 2014 by Brad Joss
Search for files and folders and don't exit the search when there is an error accessing a protected folder, just skip it.
28 May 2014 by Praveen Raghuvanshi
Hello,I need to play multiple instances of a same media file on a system and delete the file whenever last instance is deleted/closed.There is no UI involved in it and media is played/stopped on some triggers.I have been able to play the file using MediaElement and I am able to listen to...
1 Apr 2014 by Member 10239017
//// A simple Java Console for your application (Swing version)// Requires Java 1.1.5 or higher//// Disclaimer the use of this source is at your own risk. //// Permision to use and distribute into your own applications//// RJHM van den Bergh , rvdb@comweb.nlimport...
31 Mar 2014 by TorstenH.
Update:My bad, I have not realized that I already gave you the answer.You should read answers and consider to follow what we tell you.We are professionals, we do not play around.retrieving mails to jtextarea in java takes much time[^]
30 Mar 2014 by Member 10239017
Kindly edit and post your code which satisfy mu need. its an emergency.import java.awt.*;import javax.swing.*;import java.io.*;import java.util.*;import javax.mail.*; public class TextAreaDemoB extends JFrame {JTextArea _resultArea = new JTextArea(6, 35); public...
18 Mar 2014 by Johannes Bildstein
Reading and writing Bitmaps with full 16bit per channel (and possibly more)
13 Mar 2014 by Member 10667561
You'd better switch to a software-based system, like Ozeki's PBX. With its SDK you can develop call recorder in C#:public class Program{ public void static void Main(string[] args) { OpsClient opsClient = new OpsClient(); var result =...
9 Mar 2014 by Richard MacCutchan
Sending files is just the same as sending any type of data, you just need a protocol that both ends adhere to. For example you could start by sending a record containing the file name and its length in bytes. You then send the actual file broken up into manageable sized blocks (e.g. 1024 bytes...
29 Jan 2014 by Kornfeld Eliyahu Peter
Rendering PDF Content in Windows Store Apps[^]
29 Jan 2014 by Member 10158885
Hi ,i created a windows store app (windows 8.1 app ) that provide html courses and material , tests , i want to provide a certification for people who pass the exam i need the certificate to be in pdf and contain the user name , is there any way to create the pdf file then edit the name only...
2 Jan 2014 by Abhilash K M
Private Sub browseXLfile_Click(sender As Object, e As EventArgs) Handles browseXLfile.Click Dim ofd As New OpenFileDialog If ofd.ShowDialog() System.Windows.Forms.DialogResult.OK Then Exit Sub Dim nme As String = ofd.FileName Dim safename As String...
19 Nov 2013 by Jaydeep Jadav
Hello,I am developing an application to read a NFC Tag UID from NFC Reader (ACR122U-A9) device. I used JAVA and javax.smartcardio API to detect the NFC Reader and Reading NFC Tag.The functionality of the application is to display notification when the NFC Reader device is connect or...