console to service app. HELPPPPPP

  • Thread starter Thread starter DaveF
  • Start date Start date
D

DaveF

The following code does not seem to work in a Windows service. Is there
anyway I can make it work?

Stream inStream = Console.OpenStandardInput();
if (this.archiveName != null && ! this.archiveName.Equals( "-" ))
{
inStream = File.OpenRead(archiveName);
}
if (inStream != null)
{
if (this.compressed)
{
inStream = new GZipInputStream(inStream);
}
archive = TarArchive.CreateInputTarArchive(inStream, this.blockSize);
}
 
DaveF,

What exactly is failing? My guess is that it is the call to
OpenStandardInput, because there is no console associated with the service.

If this is not it, can you give more elaborate information about the
error?

Also, is the filename that is being processed on the network? If it is,
then you have to make sure the service is running under an account that has
network access.

Hope this helps.
 
There is no error, it just freezes at :

inStream = File.OpenRead(archiveName);




Nicholas Paldino said:
DaveF,

What exactly is failing? My guess is that it is the call to
OpenStandardInput, because there is no console associated with the service.

If this is not it, can you give more elaborate information about the
error?

Also, is the filename that is being processed on the network? If it is,
then you have to make sure the service is running under an account that has
network access.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

DaveF said:
The following code does not seem to work in a Windows service. Is there
anyway I can make it work?

Stream inStream = Console.OpenStandardInput();
if (this.archiveName != null && ! this.archiveName.Equals( "-" ))
{
inStream = File.OpenRead(archiveName);
}
if (inStream != null)
{
if (this.compressed)
{
inStream = new GZipInputStream(inStream);
}
archive = TarArchive.CreateInputTarArchive(inStream, this.blockSize);
}
 
DaveF,

What account is the service running under? Does that account have
rights to the file specified by archiveName?


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

DaveF said:
There is no error, it just freezes at :

inStream = File.OpenRead(archiveName);




message news:[email protected]...
DaveF,

What exactly is failing? My guess is that it is the call to
OpenStandardInput, because there is no console associated with the service.

If this is not it, can you give more elaborate information about the
error?

Also, is the filename that is being processed on the network? If it is,
then you have to make sure the service is running under an account that has
network access.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

DaveF said:
The following code does not seem to work in a Windows service. Is there
anyway I can make it work?

Stream inStream = Console.OpenStandardInput();
if (this.archiveName != null && ! this.archiveName.Equals( "-" ))
{
inStream = File.OpenRead(archiveName);
}
if (inStream != null)
{
if (this.compressed)
{
inStream = new GZipInputStream(inStream);
}
archive = TarArchive.CreateInputTarArchive(inStream, this.blockSize);
}
 
Back
Top