I'm developing Windows Service which is going to listen MS Fax service
events and update the database when Fax Job changed its status.
I need to read OutboxLOG.txt which is used by MS Fax service.
I either would like to copy it and to work with its copy to use its data
for a database update or to copy the data from OutboxLOG.txt into another
file for further processing.
I'm using :
Do
Try
System.IO.File. Copy(strSource, strDestination, True)
Exit Do
Catch
End Try
Loop
In most cases it works, but sometimes (I have no idea what it depends on) it
doesn't. I suspect that the source file is in use and is not copied.
Could anybody suggest any other approach to copy file when it's in use, or
to copy its contents?
Thank you
Al 5 1524
vul wrote: I'm developing Windows Service which is going to listen MS Fax service events and update the database when Fax Job changed its status. I need to read OutboxLOG.txt which is used by MS Fax service. I either would like to copy it and to work with its copy to use its data for a database update or to copy the data from OutboxLOG.txt into another file for further processing. I'm using : Do Try System.IO.File. Copy(strSource, strDestination, True) Exit Do Catch End Try Loop
In most cases it works, but sometimes (I have no idea what it depends on) it doesn't. I suspect that the source file is in use and is not copied. Could anybody suggest any other approach to copy file when it's in use, or to copy its contents?
Thank you Al
If the fax service is writing to the log at that moment you might be
screwed. You could try waiting a few seconds and trying it again. If
you copy it though you may lock the file while the fax program tries to
write to it. It would probably be better if you opened it w/ shared
permission and read it, then wrote it out.
Chris
Hello Vul
What version of the framework are you using?
Regards,
Simon
"vul" wrote: I'm developing Windows Service which is going to listen MS Fax service events and update the database when Fax Job changed its status. I need to read OutboxLOG.txt which is used by MS Fax service. I either would like to copy it and to work with its copy to use its data for a database update or to copy the data from OutboxLOG.txt into another file for further processing. I'm using : Do Try System.IO.File. Copy(strSource, strDestination, True) Exit Do Catch End Try Loop
In most cases it works, but sometimes (I have no idea what it depends on) it doesn't. I suspect that the source file is in use and is not copied. Could anybody suggest any other approach to copy file when it's in use, or to copy its contents?
Thank you Al
How to open the file w/ shared permission and read it? Unfortunately I have
no idea
Thank you
Al
"Chris" <no@spam.com> wrote in message
news:eL******** ******@TK2MSFTN GP10.phx.gbl... vul wrote: I'm developing Windows Service which is going to listen MS Fax service events and update the database when Fax Job changed its status. I need to read OutboxLOG.txt which is used by MS Fax service. I either would like to copy it and to work with its copy to use its data for a database update or to copy the data from OutboxLOG.txt into another file for further processing. I'm using : Do Try System.IO.File. Copy(strSource, strDestination, True) Exit Do Catch End Try Loop
In most cases it works, but sometimes (I have no idea what it depends on) it doesn't. I suspect that the source file is in use and is not copied. Could anybody suggest any other approach to copy file when it's in use, or to copy its contents?
Thank you Al
If the fax service is writing to the log at that moment you might be screwed. You could try waiting a few seconds and trying it again. If you copy it though you may lock the file while the fax program tries to write to it. It would probably be better if you opened it w/ shared permission and read it, then wrote it out.
Chris
I have both on the server. Initially I developed Windows Service in VS 2003.
But I tried to convert it to VS 2005 and tested. I did not expect any
difference in the service behavior and there was no difference.
The same failures sometime.
Thank you
Al
"Simon Murrell" <Simon Mu*****@discuss ions.microsoft. com> wrote in message
news:FC******** *************** ***********@mic rosoft.com... Hello Vul
What version of the framework are you using?
Regards, Simon
"vul" wrote:
I'm developing Windows Service which is going to listen MS Fax service events and update the database when Fax Job changed its status. I need to read OutboxLOG.txt which is used by MS Fax service. I either would like to copy it and to work with its copy to use its data for a database update or to copy the data from OutboxLOG.txt into another file for further processing. I'm using : Do Try System.IO.File. Copy(strSource, strDestination, True) Exit Do Catch End Try Loop
In most cases it works, but sometimes (I have no idea what it depends on) it doesn't. I suspect that the source file is in use and is not copied. Could anybody suggest any other approach to copy file when it's in use, or to copy its contents?
Thank you Al
Hello Vul
This should work.
byte[] bytesRead = new byte[maxBytes];
long previousSeekPos ition = 0;
int maxBytes = 4096;
FileStream fs = new FileStream(file name, FileMode.Open, FileAccess.Read ,
FileShare.ReadW rite );
if (fs.Length > maxBytes)
{
this.previousSe ekPosition = fs.Length - maxBytes;
}
this.previousSe ekPosition = (int)fs.Seek(th is.previousSeek Position,
SeekOrigin.Begi n);
int numBytes = fs.Read(bytesRe ad, 0, maxBytes);
fs.Close();
this.previousSe ekPosition += numBytes;
StringBuilder sb = new StringBuilder() ;
for (int i=0; i<numBytes; i++)
{
sb.Append((char )bytesRead[i]);
}
// Your data will then be in sb.ToString();
Regards,
Simon
"vul" wrote: I have both on the server. Initially I developed Windows Service in VS 2003. But I tried to convert it to VS 2005 and tested. I did not expect any difference in the service behavior and there was no difference. The same failures sometime.
Thank you Al
"Simon Murrell" <Simon Mu*****@discuss ions.microsoft. com> wrote in message news:FC******** *************** ***********@mic rosoft.com... Hello Vul
What version of the framework are you using?
Regards, Simon
"vul" wrote:
I'm developing Windows Service which is going to listen MS Fax service events and update the database when Fax Job changed its status. I need to read OutboxLOG.txt which is used by MS Fax service. I either would like to copy it and to work with its copy to use its data for a database update or to copy the data from OutboxLOG.txt into another file for further processing. I'm using : Do Try System.IO.File. Copy(strSource, strDestination, True) Exit Do Catch End Try Loop
In most cases it works, but sometimes (I have no idea what it depends on) it doesn't. I suspect that the source file is in use and is not copied. Could anybody suggest any other approach to copy file when it's in use, or to copy its contents?
Thank you Al This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: matt |
last post by:
I have compiled some code, some written by me, some compiled from
various sources online, and basically i've got a very simple flat file
photo gallery. An upload form, to upload the photos and give them a
caption, storing the caption and filename in a text file. It's a bit
buggy when removing the photos and captions from the file, and also in...
|
by: Dave Smithz |
last post by:
Hi There,
I have a PHP script that sends an email with attachment and works great when
provided the path to the file to send.
However this file needs to be on the same server as the script.
I want to develop a webpage where people can send attachments that are
stored on their local PC.
|
by: Joseph |
last post by:
Hi,
I'm having bit of questions on recursive pointer. I have following
code that supports upto 8K files but when i do a file like 12K i get a
segment fault. I Know it is in this line of code. How do i make the
last pointer in the indirect sector that has another level of indirect
pointer, and be defined recursively to support infinite...
|
by: StGo |
last post by:
How can i read/write file's custom attributs(like subject,author...) in
C#???
Thanks :))
|
by: Lokkju |
last post by:
I am pretty much lost here - I am trying to create a managed c++
wrapper for this dll, so that I can use it from c#/vb.net, however, it
does not conform to any standard style of coding I have seen. It is
almost like it is trying to implement it's own COM interfaces...
below is the header, and a link to the dll+code:
Zip file with header,...
| |
by: Sky Sigal |
last post by:
I have created an IHttpHandler that waits for uploads as attachments for a
webmail interface, and saves it to a directory that is defined in
config.xml.
My question is the following:
assuming that this is suppossed to end up as a component for others to use,
and therefore I do NOT have access to their global.cs::Session_End()
how do I...
|
by: Roy |
last post by:
Hi,
I have a problem that I have been working with for a while.
I need to be able from server side (asp.net) to detect that the file i'm
streaming down to the client is saved completely/succsessfully on the
client's computer before updating some metadata on the server (file
downloaded date for instance)
However,
All examples i have tried,...
|
by: Shapper |
last post by:
Hello,
I created a script to upload a file.
To determine the file type I am using userPostedFile.ContentType.
For example, for a png image I get "image/png".
My questions are:
1. Where can I find a list of all the types which can be returned?
For example, if it is a Word document will it return "document/doc".
|
by: troutbum |
last post by:
I am experiencing problems when one user has a document open through a
share pointing to the web site. I use the dsolefile to read the
contents of a particular directory and then display them in a
datalist. When the next user selects trys to run the page, the page
fails and I get a generic error message from the stack trace. I am
assuming...
|
by: thjwong |
last post by:
I'm using WinXP with Microsoft Visual C++ .NET
69462-006-3405781-18776, Microsoft Development Environment 2003 Version
7.1.3088, Microsoft .NET Framework 1.1 Version 1.1.4322 SP1
Most developers said to me that they have no problem doing that, but
the following project file is said to be corrupted while opening in the
IDE, it is the project...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |