Click here to Skip to main content
15,901,283 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 Title

IO 

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...
5 Apr 2018 by David Crow
I suspect you want something like: InputStream stream = manager.open("firmware/" + file);
18 Mar 2014 by Johannes Bildstein
Reading and writing Bitmaps with full 16bit per channel (and possibly more)
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 Jan 2019 by Ray K
Extending BinaryReader/Writer to support a different byte order, string and date formats, and advanced navigation in binary files
9 Nov 2012 by mlzg4
This stream implementation is fast, thread-safe, easy to use, and very useful for debugging large distributed or concurrent projects.
22 Aug 2013 by hk.v
Is it possible to access the raw data (like traversing sector by sector) of hard disk using java ? If not, please tell the reason.....thnx in advance
22 Aug 2013 by Richard MacCutchan
See https://www.google.com/search?q=java+raw+disk+io[^].
23 Jul 2020 by honey the codewitch
Add progress reporting to your downloading or copying using this code
4 Jan 2012 by Harshad-HBK
Hi to all,I am checking a notepad file which contains almost 5000 lines of records.I have to insert 10 rows of records after each 500 lines in the same file.After doing the job I will have a file which will contain total 5100 lines of records.Original...
4 Jan 2012 by CPallini
There's no 'insertion' functionality for files: you have to create a new file with the appropriate content:Read line by line from input file (you may use the StreamReader.ReadLine Method[^]) and output the read line to the ouput file, until line count reaches 500.Then write the '10 rows' to...
4 Jan 2012 by Wendelius
One quite brute-force way is to read all the lines to an array or a list, add necessary items and then write the contents to the file. For example something like:List lines = System.IO.File.ReadAllLines("...").ToList();lines.Insert(500, "some string");lines.Insert(501,...
30 Jan 2012 by Auric Consulting, LLC
In the code below, there is a BeginRead call which I want to use in an async manner. (warning, code is cobbled together using a variety of code samples found lying around on the internet!) With this sample, I expect the BeginRead to return immediately, and then the callback to be hit later on...
30 Jan 2012 by Herman<T>.Instance
static public void BeginAsyncReadshould bestatic public IAsyncResult BeginAsyncRead
4 Apr 2011 by funniezatee
Hi all,I am in a fix for a better solution here for my digital web shop.My situation is that I have 6 packages for sale, each containing 1GB of files on my server.These files will be uniquely watermarked before being compressed to allow fordownload by each buyer - reason to uniquely...
4 Apr 2011 by Peter_in_2780
Is there any reason you can't do the watermarking on-the-fly as you are serving the download? That way, all you need to store for more than a few minutes is stuff you're keeping anyway - customer name and watermark key. To do this, you will probably need to set up your watermarker as an external...
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
15 May 2011 by kribo
How to insert images / binary data into a database.
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...
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`...
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}",...
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 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...
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 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...
9 Mar 2011 by Deepthy haridas
Hi!I am trying to connect my employee registration code with a RFID reader. I am not able to read from COM1 port. I used all the tecniques provided by google to my best knowledge.give some solution...Can somebody please help me in this?Thanks in advance!
9 Mar 2011 by Manfred Rudolf Bihy
I'll give you a little help first in structuring your questionable approach above:A. Be ever specific:Exact Java Version (e.g. ME 1.6)Which RFID reader (Product name and version)Connection cable typeShow your sample code and tell us your issues with itB. Be ever...
8 Jan 2012 by Manish Kumar Namdev
Hello Friends I'm using Silverlight in my asp.net application.I'm trying to create a folder in my local hard drive "D" using IsolatedStorageFile.It is creating the directory when I give only Directory Name but I'm not getting where it exists.And, when I give complete path...
8 Jan 2012 by Abhinav S
These folders are created in a temporary storage location (like a cookie).You cannot directly access the harddrive path in Silverlight (unless you run with elevated permissions).That is the whole idea behind running Silverlight in a sandboxed environment.
30 Jul 2012 by Behnam Mohammadi
hii'm sorry for my poor english.i want create a gallery without database.for categorys create FOLDERfor photo items upload photos on folderbut i ask this method has problem or is true?if anyone has better sulotion please saythank you.
30 Jul 2012 by El_Codero
Hi,I'm sure you can use this open source photo gallery library from codeplex, read the code, try to understand it and fit it to your pruposes.http://photohandler.codeplex.com/[^]Regards
17 Oct 2012 by Member 9522119
I want to read a txt file and add all words to a collection but dont add same words after write txt by the collection. how I do it. May I use how collection for different words.
17 Oct 2012 by fjdiewornncalwe
We're not going to do your homework for you, but I will give you some pointers.1) You'll need a collection object to put the words into as you read them.2) Before you actually insert a found word into the collection, you'll need to make sure that the word doesn't already exist in the...
3 Jul 2015 by Shivachalappa Gotur
Detecting USB Modem Device using C#.NET
18 May 2011 by Freeboss
I'm trying to get all the subDirectories of a directory using the:DirectoryInfo.GetDirectories("*",SearchOption.AllDirectories).On all folders i have tested this is returns correct results BUTIf u execute this on "C:\Windows\System32 you will find 2 problems:1.(Solved) Is about a...
18 May 2011 by Dave Kreskowiak
I can't see any problem with GetDirectories. Then again, I'm an admin on my own machine and don't have UAC running.From what I can tell, you cannot get all the folders without being an admin on the machine and running the code as an admin. If you have UAC enabled on your machine, your code...
23 May 2011 by Freeboss
I found the solution.It's not some folders that are secured or anything..If it was this even Windows Explorer wouldn't show em.Anyway Visual Studio 2010 with or without Sp1 has by default "Platform Target" x86.So if you run this on a x64 machine, the Framework does something like...
23 Nov 2011 by Freeboss
Post is old but for future reference here is the solution i found:http://alphafs.codeplex.com/[^]
25 Jun 2011 by se.nishant
// I want dir command to execute in project folder which means I want that this will show the files of project folder...using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;namespace filehider{ ...
25 Jun 2011 by Sergey Alexandrovich Kryukov
There is no such things as "dos command" in Windows. What are your trying to do in ASP.NET makes no sense at all and would be extremely bad in general.You need to use System.IO.Directory.GetFiles, see http://msdn.microsoft.com/en-us/library/system.io.directory.aspx[^].There is a little...
25 Jun 2011 by Espen Harlinn
You may find this article to be of some interest:File System Browsing in ASP.NET: New Approach vs. Old Approach[^]Best regardsEspen Harlinn
5 Jan 2023 by Michael Sydney Balloni
See how Rust stacks up against C-ish, C++, and C#
16 Nov 2011 by sahabiswarup
I want to modify a notepad; and that is not a big deal.When i save the data automatically an extra space over there.Textbox data is very case sensitive; actually it saves server name so an extra space will hamper in the connection.Any suggetion...Thanks in advance
16 Nov 2011 by Binu Varghese K
Now you are doing is writing line by line.Which will generate a new line after writing each line by default. So the better idea is to us writer.write("your text") instead of writer.writeline("your text").
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.
23 Jul 2012 by Behnam Mohammadi
I want delete a file but an error occured please help me.==============================The process cannot access the file 'D:\My Project\AzadUniv\New\12\GUI\Upload\NewsImage\5564868769930125853-Image' because it is being used by another process.==============================string...
23 Jul 2012 by fjdiewornncalwe
You are attempting to delete the file that was read in within the thumbnail object. Perhaps if you disposed of the thumbnail object, the file resource would be released.
27 Nov 2012 by lilyNaz
I have written a code in C++ builder in which I use header FileCtrl.hpp and I call SelectDirectory procedure so that the user can choose the a directory. When I change the drive to empty floppy disk or DVD drives, I get Exception EInOutError. I used try catch, bu it didn't work.try{ ...
29 Nov 2012 by Dharmateja Challa
To trap EInOutError enable "I/O checking" in the Pascal tab of the project options in order for EInOutError exceptions to be trapped. It seems EInOutError is a delphi class
22 Dec 2012 by lilyNaz
I used SHBrowseFolder instead and everything turned out OK.
20 Jan 2012 by Harshad-HBK
I want to export a sql datatable to notepad file without looping through each row.I have a data table, containing almost 60 to 70 lacks of rows.It is very time consuming to loop through every row and write it in text file.Tools:Framework 2.0Language VB.NetPlease Advice...
20 Jan 2012 by E.F. Nijboer
If you use the example in the following link I believe you when you say it is very slow.http://www.dotnetspider.com/resources/28359-Export-DataGridView-into-csv-file.aspx[^]The reason for the code to be slow is the fact that it concatenates strings over and over again. (eg. strExport +=...
1 Jan 2013 by kosay85
HelloI need too monitor all local driver so I code thisPrivate Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim allDrives2() As IO.DriveInfo = IO.DriveInfo.GetDrives() Dim dd As IO.DriveInfo Dim N As Integer = 0 Dim T(10)...
10 Jan 2013 by Logi Guna
First:Dim T(10) As FileSystemWatcherThe number of drives might more than thatSecond:T(N) is null or Nothing, new instance of FileSystemWatcher requiredPrivate Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim allDrives2() As...
10 Jan 2013 by Dave Kreskowiak
You have a bigger problem. The FSW was not designed to watch an entire drive. You'll have problems with it and miss events. It may also use enough resources to bring the system to a crawl.Test TEST and MORE TEST!
29 Jan 2012 by Zillo7
I'm currently working on a project that would prevent write access to a usb flash drive when it's inserted into a machine. I've looked into using the FileIOPermission class to make the assembly have read-only access, but would using that class prevent other applications from writing to the...
29 Jan 2012 by BillWoodruff
The first thought that comes to mind is using a USB flash-drive that can be password-protected. This company claims its password-protection software is free: [^], but I have never used it.This CP article may be helpful as a starting point: "Developing a USB Storage Device Protection Tool...
12 Jul 2011 by Member 8015046
I am not sure if this is the place to ask. It may be a simple error. But I have a webservice that calls filestream writer.I have this in the beggining of my constructor. If tracing is set to true, then it changes the instance variables fs and w to those. if...
12 Jul 2011 by JOAT-MON
Maybe you should try disposing the streams, not just close them:w.Dispose();fs.Dispose();
12 Jul 2011 by TRK3
Is this happening on the very first instance that's created? Or only on all the rest of them?See:http://msdn.microsoft.com/en-us/library/47ek66wy.aspx[^]Which states in part:"requests to open the file for writing by this or another process will fail until the FileStream object...
21 Aug 2013 by Paul Unsy
Hi GuysI have a strange issue that I'm struggling to solve.I have a FileStream (used to be just a SteamReader) that opens a file on the network. It works fine on my machine and the test machine (both x64 windows 7 pro) and opens the file instantly.However, when on it's server...
21 Aug 2013 by Paul Unsy
Ok... Thanks for your comments guys, however it has started working now... Not made any changes, and I have no idea what was causing it.It looks like I'm going to have to do some environmental diagnostics as this is supposed to be running as a service, and I don't want to lose stuff because...
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.
30 May 2012 by Harshad-HBK
hi to all,I am working with text files in desktop app(vb.net). Framework is 3.0.I have a several(e.g. 10) text files each containing 10,000 records.e.g.17725534 87489382983417725535 31355413215417725536 981521451554and so on.I have another file containing 200...
19 May 2012 by Dave Kreskowiak
Your description is pretty confusing. We have no idea what you're really having a problem with, so, the generic explanation:You have to read the file line by line to find what you're looking for. If you don't find it, write the line out to a new file.If you do find what you're looking...
30 May 2012 by Jαved
Hi Harshad,Refer this link to achieve your goal-searching-for-line-of-one-text-file-in-another-text-file[^]Or follow these steps-1. read both files line by line [Link][^]2. split each line on their white spaces [Link][^]3. for both files, create a 2 dimensional array [Link][^]4....
8 Apr 2016 by V.
Convert FITS file to known image formats and use those images for a "zooming" functionality (image transparency)
23 Nov 2012 by jamiebones
Hello please i am trying to save the result of an operation where i modified some text in a sample application. The problem is i am having difficulty in trying to loop through all the data.Trying to print out my result to a file, i get only the last line of the file.My code simply refuse to loop...
23 Nov 2012 by nagalkumar
This code is workingUsing myreader As StreamReader = New StreamReader("C:\Users\Jamiebones\Desktop\ConsoleApplication1\ConsoleApplication1\PHONE NUMBERS.txt") While Not (myreader.EndOfStream) Dim line As String = myreader.ReadLine Dim...
23 Nov 2012 by OriginalGriff
That is some very, very odd code - and it is difficult to work out exactly what to say here!I am assuming that you want to read the strings from a file, and write them to another file, yes?So why are you creating the file anew each time you read a line from the input file?You have two...
18 Feb 2022 by honey the codewitch
Run your IoT display driver independent of the bus it uses, whether I2C, SPI or parallel
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...
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....
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...
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...
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...
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)[^]
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.
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
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...
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...
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...
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.
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...
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)[^].
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...
29 Jan 2014 by Kornfeld Eliyahu Peter
Rendering PDF Content in Windows Store Apps[^]
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 -...
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...
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...
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...
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...
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[^]
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...
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...