Jaggu
Jaggu

Reputation: 6428

File.Open just hangs and does nothing

I've never came across this issue. Can anybody tell me why does this code just hang and hang forever:

 FileStream stream = File.Open("abc.xls", FileMode.Open, FileAccess.Read);

I am using Visual Studio 2010 Premium edition, Windows 7.

What can be the possible causes? Either it should throw exception or just run fine. Why does the program just hang and never reach the next line of code after this?

Thanks in advance :)

Upvotes: 1

Views: 659

Answers (2)

Lucero
Lucero

Reputation: 60276

Can this same file be opened fine with other applications? Is it on a network or any other special kind of drive which may cause a delay? Are you sure that it is this one line which blocks (the debugger is sometimes a line off)?

Note: In contrast to the other answer given, I believe that the size should not have any impact on the performance when opening a stream. It doesn't actually read or do anything but opening the file.

Upvotes: 1

saj
saj

Reputation: 4806

A possible cause could be the size of the file, how big is it?

Upvotes: 1

Related Questions