Solved

Open two files as process

Posted on 2011-02-25
6
232 Views
Last Modified: 2012-05-11
How to open 2 files at same time as process?  Do I need 2 process?

0
Comment
Question by:ToneElec
  • 3
  • 3
6 Comments
 
LVL 74

Expert Comment

by:käµfm³d 👽
ID: 34984071
What kind of files?
0
 
LVL 3

Expert Comment

by:sergiobg57
ID: 34985492
Open two files as process?

At the same time is impossible, even with 2 processes.
What you can do is use 2 threads for that purpose but it will still not be at the same time.

using System.Diagnostics;
System.Diagnostics.Process.Start("cmd");

Open in new window

//use your filename instead of cmd
0
 
LVL 74

Accepted Solution

by:
käµfm³d   👽 earned 125 total points
ID: 34985558
>>  At the same time is impossible, even with 2 processes.

Really? Then what does this code do?
using (StreamReader reader1 = new StreamReader("file1.txt"))
{
    using (StreamReader reader2 = new StreamReader("file2.txt"))
    {
        // is this not two files open at the same time  ; )
    }
}

Open in new window

0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 3

Assisted Solution

by:sergiobg57
sergiobg57 earned 125 total points
ID: 34985580
No, they are being opened consecutively.
One after another.

The way the microprocessor works for parallelism, makes this task impossible.
It's constantly scheduling threads.
One run for sometime, then it's scheduled and another one starts to run for the same amount of time.

That's how it's done.
StreamReader will just open so fast that you might not realize the difference but the difference is still there and if he has any needs to open those files really at the same time, then he will get frustrated.


But i was wrong about 2 processes.
In multi-processor systems it is possible but not likely to happen. =/
0
 
LVL 74

Expert Comment

by:käµfm³d 👽
ID: 34985612
My guess would be that the question is not about opening the files at the same exact instance of time, but I could be wrong  = )
0
 
LVL 3

Expert Comment

by:sergiobg57
ID: 34985674
That question is a bit confusing. hehe
Let's see which guess is right.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now