Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Open two files as process

Posted on 2011-02-25
6
Medium Priority
?
246 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 75

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 75

Accepted Solution

by:
käµfm³d   👽 earned 500 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 3

Assisted Solution

by:sergiobg57
sergiobg57 earned 500 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 75

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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Simulator games are perfect for generating sample realistic data streams, especially for learning data analysis. It is even useful for demoing offerings such as Azure stream analytics, PowerBI etc.
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Suggested Courses

885 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