.NET Framework Bookmark and Share   
 index > .NET Base Class Library > text file hangs while opening using process.start() through IIS
 

text file hangs while opening using process.start() through IIS

Dear All,

I trying to access a text file using below code.

System.Diagnostics.Process.Start(@"C:\abc\abc.txt");

through IISwhen I open it just open a frame kind of thing and it hangs in XP and in windows 2003 nothing happens.. code executes without any error

· I have added <identity impersonate="true"/> in web.config.

· I have added aspnet account to administrator group.

· I have added NETWORK SERVICES, ASPNET and IUSR_systemname to the sucurities tab of the folder

· In IISAdmin service I have enabled “Allow services to interact with desktop�/font>

·

After doing all these still it hangs ..

Not only text file any sort of file I am trying to open it hangs in XP and nothing happens in windows server 2003.

But when I try to open using visual studio in debug mode it works file it opens the files.

Please help me out

Thanks,

-Krishna

Kitty Krishna

Hi Krishnaveni,

Here is a thread about how to run a process by using specific user account, Perhaps you will get some helpful information.

http://forums.asp.net/t/1199997.aspx

For more information about the process class, please refer the following Microsoft web site.

http://msdn2.microsoft.com/en-us/library/system.diagnostics.process.aspx

Regards,

Xun

Xun Ye

I think the best approach here is to use class File, FileInfo, DirectoryInfo, TextReader and StreamReaderfrom System.IO especially that you are working on web application.

//Find Directory of the file

DirectoryInfo dir = new DirectoryInfo(Server.MapPath("") + @"\YourFolder");

//Iterate the file from directory
foreach (FileInfo file in dir.GetFiles(String.Format("*_{0}.txt", User.Identity.Name)))
{

//Open and read the file
TextReader text = StreamReader(file.FullName);

Console.WriteLine(text.ReadLine());
}

Bermil M. Espina

> But when I try to open using visual studio in debug mode it works file it opens the files.

You are using the test web server that comes with Visual Studio -- not IIS. This test server is actually a standalone, Windows GUI application running under your user. Therefore, you are able to display notepad (or another editor) successfully in testing.

As the previous poster has indicated, the IIS service / worker process is not designed to display a GUI.

BinaryCoder

Hi Krishnaveni,

Here is a thread about how to run a process by using specific user account, Perhaps you will get some helpful information.

http://forums.asp.net/t/1199997.aspx

For more information about the process class, please refer the following Microsoft web site.

http://msdn2.microsoft.com/en-us/library/system.diagnostics.process.aspx

Regards,

Xun

Xun Ye

You can use google to search for other answers

Custom Search

More Threads

• what does msdn mean by the sentence below...????
• Un Install the particular software
• FileSystemWatcher reliability
• Visual Studio 2005 & .Net 1.1/1.0?
• receiving data
• Only one connection for a port
• ArrayList.Contains Bug
• Type Casting in CodeDom
• To Identify the Embedded Object using Excel Interop
• Do we have an API that load the config from string?