Click here to Skip to main content
15,880,796 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 Score

IO 

23 Apr 2021 by honey the codewitch
BinaryReader needs a better way to read strings and types. Here's a quick and dirty fix
1 Nov 2018 by Alexander Eremeev
The Windows kernel-hacking library and development framework written on C++17
9 Dec 2022 by Bruno van Dooren
How to implement named pipe server for communicating with client apps
8 Apr 2016 by V.
Convert FITS file to known image formats and use those images for a "zooming" functionality (image transparency)
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...
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...
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...
28 May 2018 by Marco Bertschi
The presented code snippet compares two given files using the IEqualityComparer.
5 Jun 2011 by ambarishtv
below code shows the given text and their mirror position in picture box.Here i'm using System.Drawing.Drawing2D.Matrix class private void pictureBox1_Paint(object sender, PaintEventArgs e) { Graphics graphics = e.Graphics; graphics.DrawString("Ambarish!",...
20 May 2012 by vangapally Naveen Kumar
first you have to store excel data in datatable,you can store data in datatable asstring constring="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\MySpreadsheet.XLS;Extended Properties=""Excel 8.0;HDR=Yes;IMEX=2"""datatable dt=new datatable();Oledbconnection con=new...
15 Jul 2012 by OriginalGriff
In the comment you link to you give the vital info that you don't here: you don't have admin rights on the target machine. This is quite likely to be the reason for the problem.Personally, for a single bit input, I would not use a parallel port - I would use one of the control lines on the...
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.
1 Aug 2012 by OriginalGriff
Look at string.Join:string[] lines = { "line1,", "line2,", "line3," };string s = string.Join("", lines);
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.
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...
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...
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}",...
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...
18 Feb 2022 by honey the codewitch
Run your IoT display driver independent of the bus it uses, whether I2C, SPI or parallel
19 May 2011 by Peter_in_2780
Since Exception has what is effectively a copy constructor, you can do this:FileNotFoundException saveException = null;try { readfile(); // might throw FileNotFoundException} catch (FileNotFoundException fnfEx) { saveException = new FileNotFoundException(fnfEx);} finally { ...
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
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...
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...
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...
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.
24 Sep 2012 by Kuthuparakkal
try:http://blogs.msdn.com/b/jeffrey_wall/archive/2004/09/13/229137.aspx[^]
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...
22 Aug 2013 by Richard MacCutchan
See https://www.google.com/search?q=java+raw+disk+io[^].
2 Sep 2013 by Rakesh Meel
will Help youstring strvalue = string.Empty; using (System.IO.StringReader sr = new StringReader("c:\aaa.txt")) { string[] strdata = sr.ReadToEnd().Split(new char[] { '\n' }); foreach (string item in strdata) { ...
29 Jan 2014 by Kornfeld Eliyahu Peter
Rendering PDF Content in Windows Store Apps[^]
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 =...
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...
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...
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.
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...
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...
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.
5 Apr 2018 by David Crow
I suspect you want something like: InputStream stream = manager.open("firmware/" + file);
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
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...
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[^].
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 May 2011 by Member 7751939
In Java, I need to get the exact causes whether is FileNotFound or normal IOException. Which I mean if it is Filenotfound exception, do not loose the FilenotFound cause. If it is other IOException, show IOException. No overwritten the causes.I need to accurately describe the...
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...
27 May 2011 by BobJanova
You are explicitly seeking to the position of the first cell. If you don't want to write to that position in the file (which won't work in all cases anyway as your cell record is not a fixed length), seek to the end.If you want to be able to overwrite a single record in place, you need to...
4 Jun 2011 by Christian Graus
You have the position of the ellipse, and you have the text, which you can write with WriteString ( or DrawString, I forget ). So, where is the issue ?
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{ ...
26 Aug 2011 by Tejas Vaishnav
Hello all...I have problem while uploading a file to server using file upload control and webservice.i have registration form contains user image and also .doc or .pdf file, now i have to upload that file to the server side directory using a webservice.
26 Aug 2011 by Shahan Ayyub
Check this thread:upload image to web service using c#[^]
26 Aug 2011 by Abhinav S
IF you are using .Net 2.0, you will need to use Web Service Extensions[^] and MTOM.
25 Oct 2011 by medoded2009
I want to analyze Java source code and produce some kind of output based on its contents, I started by moving the source code to txt file so I can pars it, then I would search for specific word in each test case if I found it I will present it in the produced xml file, that words I'm looking for...
25 Oct 2011 by Manfred Rudolf Bihy
If the words Cell and Engine have to be Java types[^], as your usage sample suggests, there is no way around using a real parser that can parse the Java language. If the words can appear in any context you could go after them with regular expressions[^] making sure that the words you are...
23 Nov 2011 by Freeboss
Post is old but for future reference here is the solution i found:http://alphafs.codeplex.com/[^]
23 Nov 2011 by Yousif Mazeh
hi, i have a formatted excel file that i need to write some specific data from my c# application into specific columns in the excel file.so i need some help on how to write data from c# to excel and to target the columns that i should write into.
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...
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.
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 +=...
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 Harshad-HBK
Hi to all,I have developed a software (CRM) and sending quotations from Microsoft Outlook.All the mail credentials for the mail comes from server pages.I have used 'Microsoft.Office.Interop' namespace.Following is the code for reference :-Imports System.NetImports...
29 Jan 2012 by Rajesh Anuhya
Go Through the below link, here is the example Here[^]Thanks--RA
30 Jan 2012 by Herman<T>.Instance
static public void BeginAsyncReadshould bestatic public IAsyncResult BeginAsyncRead
2 Apr 2012 by cpquest
Hi all,i have some doubts in creating xml from a class that i have. I need to grenerate a xml file in my local filesystem the Nodes and Data of a xml should be Generated once from the first time. What ever changed made in the data should be saved in the genereated XML in my local file system...
20 May 2012 by MacParekh
Hi all,I am working on VB.net Desktop Application. I want to upload Excel sheet to Database(sql server),And Display data in Gridview.Is there any IO property for that?Please give me solution if You have.Thanks in Advance.
20 May 2012 by Om Prakash Pant
You can directly show data from excel:http://vb.net-informations.com/datagridview/vb.net_datagridview_import.htm[^]Import data from excel to sql server:Import Data from Excel to SQL Server[^]Display data from sql server in...
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....
15 Jul 2012 by lukeer
Hello experts,I'm trying to read one bit from an external source. Dependent upon available hardware, I chose the parallel port's BUSY pin. It works on my development PC but not on the target machine. I posted the details here[^].Has anyone had similar issues using the parallel port?And...
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
1 Aug 2012 by Kamalkant(kk)
If u want to read from .txt file then below code will helppublic static DataTable exceldata(string filePath) { DataTable dtexcel = new DataTable(); var filename = filePath; var reader = ReadAsLines(filename); //...
16 Oct 2012 by Pasan Eeriyagama
There is a file copying is being done in our C# program. At the moment it's just copying when the file is available on a shared location which is written by some external 3rd party s/w. When our program is copying this text file it may not be fully written to the disk, in that case partially...
17 Oct 2012 by Sushil Mate
Something like this you can try. try{ using (FileStream fs = File.Open("FileName", FileMode.Open, FileAccess.ReadWrite, FileShare.None)) { //File copy }}catch (Exception){ // File is in use. }Or you can use this FileSystemWatcher [^]
13 Nov 2012 by Zied Rebhi
Hi everyone :)I would like to explain that: in a company there are telephones connected to a standard telephone to make calls I want to connect this PABX to a computer for processing transactions using a application c #:For telephone calls: This application saves the caller's number i...
21 Nov 2012 by jamiebones
Please i am trying to write the result of a loop in my code into a text file that on the harddisk. I am getting an IOEXECPTION error that the file you are trying to access is currently used by another process.Sub Main() Using myreader As StreamReader = New...
21 Nov 2012 by Dave Kreskowiak
First the writer.Close (not CloseStream!) should be inside the If block directly above it, not after the End If.Second, the path seperator character in Windows is "\", not "/".
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...
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...
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
2 Dec 2012 by Franklin Barnett
I have a file which should be opened in a third-party program. That file is encrypted until it is needed. When the user runs my C# program, it will decrypt the file, open it with the third-party software, then when the software is done, it will re-encrypt the file. The third-party cannot do the...
2 Dec 2012 by Expert Coming
Not really. The only option I really see is decrypting the file in-memory and passing that to the third-party application.The flaw really lies in the fact that the third party application doesn't do the encryption/decryption itself AND doesn't provide a way to pass in the decrypted information.
6 Dec 2012 by Franklin Barnett
Found out my issue. Granted the whole scheme is a bit unorthodox, but modifying the target application itself isn't practical.I ended up revisiting the Dokan solution. Dokan creates a sort of virtual hard drive out of an empty folder or creates a new drive. This time I successfully modified...
22 Dec 2012 by lilyNaz
I used SHBrowseFolder instead and everything turned out OK.
7 May 2013 by Rahul Krishnan R
Hi,How can I get a list of all files and folders of a directory in a grid view in the form as shown below using c# windows .ParentFolder ChildFolder FilenameAAAA aaaaaa aaa.txtThanksRahul
7 May 2013 by CPallini
The DirectoryInfo[^] class provides all you need, namely the GetFiles, GetDirectories methods and the Parent property.
7 May 2013 by lukeer
Use the System.IO.Directory.GetFiles[^] and GetDirectories[^] methods to retrieve the information.Then you can display it in a DataGridView[^] just like any other pile of strings.MyDataGridView.Rows[whateverRowNumber].Columns["ChildFolderNameColumn"].Value = childFolderName;Or you can store...
7 May 2013 by bdeklerk
private void btnGetFolders_Click(object sender, EventArgs e) { string[] dirs = Directory.GetDirectories(@"DirectoryPath eg. E:\Music"); foreach (string dir in dirs) { lstMusic.Items.Add(dir); //Adding the list of...
7 Aug 2013 by Member 10153188
I'm trying to get a FIX message from the client side to server side, where I created a UI for the server. The only problem is that, when I try to output the message onto the textarea, it won't update, while the rest of the program work, such as the text fields will all properly update, when...
7 Aug 2013 by Shubhashish_Mandal
This is a known issue. See thishttp://www.javamex.com/tutorials/threads/invokelater.shtml[^]
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...
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
2 Sep 2013 by Rahul Krishnan R
Hi,I want to read a particular word from a text file. For example AAA.txt is my text file and it contains words as shown belowName := DellServer := DataserverUser := MikeThe data i want is Dataserver. How do I get it?
2 Sep 2013 by Bernhard Hiller
Do you really use Key :=Valueor rather key=value? In the last case, you can use the Windows API for ini-files.Otherwise, you have to read the file line by line and parse each line with a regex.
2 Sep 2013 by Thomas ktg
Use the below code to get the specified string in the file.txtAfter that you remove the strings upto "=";string regexMatchString= "Server :=Dataserver";string text = System.IO.File.ReadAllText(@"C:\Users\Public\TestFolder\Textfile.txt");string matchedString = Regex.Match(text,...
2 Sep 2013 by Mahendran Murugesan
Hi,Please find the solution of the same.Note: I have used the 'Server' as keyword to find the DataServer value.Quote:/// /// This method will search for a Key value and return its value /// ///...