Click here to Skip to main content
16,006,475 members
Home / Discussions / C#
   

C#

 
GeneralRe: largest size of a byte array Pin
Derek Bartram21-Mar-08 15:31
Derek Bartram21-Mar-08 15:31 
GeneralRe: largest size of a byte array Pin
PIEBALDconsult21-Mar-08 17:46
mvePIEBALDconsult21-Mar-08 17:46 
GeneralRe: largest size of a byte array Pin
Derek Bartram22-Mar-08 0:51
Derek Bartram22-Mar-08 0:51 
GeneralRe: largest size of a byte array Pin
Colin Angus Mackay22-Mar-08 3:16
Colin Angus Mackay22-Mar-08 3:16 
GeneralRe: largest size of a byte array Pin
PIEBALDconsult22-Mar-08 6:09
mvePIEBALDconsult22-Mar-08 6:09 
GeneralRe: largest size of a byte array Pin
Derek Bartram22-Mar-08 6:35
Derek Bartram22-Mar-08 6:35 
GeneralRe: largest size of a byte array Pin
Jimmy Zhang24-Mar-08 5:29
Jimmy Zhang24-Mar-08 5:29 
QuestionSystem.IO functions not working in Windows Service Pin
MNFlyer21-Mar-08 9:46
MNFlyer21-Mar-08 9:46 
I created a C# Windows Service to clean up files on some equipment PCs. Along with the service I created a configuration Windows App. that allows me to install, start, stop, uninstall the service and create an configuration XML file to change folder locations and such.

Purpose:
The service uses an OnTimer event to periodically check a folder for files. It then creates a backup copy on a network drive and deletes the local file.

Problem:
The following code does not work in the service but will work if performed from a button in the configuration app. The AddToFile function is working in the service as it just writes the string to a text file.

The Service is configured to log on as a local system.

Question: Why does this not work from within the service?

//Code Section
AddToFile(DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToLongTimeString() + " Copying Reports to Network");
foreach (string sfi in Directory.GetFiles(SC.LocalReportFolder))
{
FileInfo fi = new FileInfo(sfi);
FileInfo fn;
if (SC.CU.AppendMachineName) //Configuration file variable
{
//Adds the machine name to the report
string nwname = fi.Name.Replace(fi.Extension, "_" + SC.MachineName + ".txt");
fn = fi.CopyTo(SC.CU.NetworkReportFolder + "\\" + nwname, true);

}
else
{
fn = fi.CopyTo(SC.CU.NetworkReportFolder + "\\" + SC.MachineName + "\\" + fi.Name, true);
}

fn.Refresh();
//If the copy was successful then delete the local file.
if ((fn.Exists)&&(SC.CU.DeleteLocalReport))
{
fi.Delete();
}
}

//End of Code
GeneralRe: System.IO functions not working in Windows Service Pin
Robert Rohde21-Mar-08 11:58
Robert Rohde21-Mar-08 11:58 
GeneralRe: System.IO functions not working in Windows Service Pin
MNFlyer21-Mar-08 15:24
MNFlyer21-Mar-08 15:24 
GeneralRe: System.IO functions not working in Windows Service Pin
PIEBALDconsult21-Mar-08 17:48
mvePIEBALDconsult21-Mar-08 17:48 
GeneralRe: System.IO functions not working in Windows Service Pin
#realJSOP22-Mar-08 2:18
professional#realJSOP22-Mar-08 2:18 
GeneralClient side soap request issue. Pin
woodrvr21-Mar-08 7:16
woodrvr21-Mar-08 7:16 
GeneralRe: Client side soap request issue. Pin
led mike21-Mar-08 9:33
led mike21-Mar-08 9:33 
GeneralRe: Client side soap request issue. Pin
woodrvr21-Mar-08 9:59
woodrvr21-Mar-08 9:59 
Question[Message Deleted] Pin
Roman Olney21-Mar-08 6:13
Roman Olney21-Mar-08 6:13 
GeneralRe: c# Online Quotation System Pin
pmarfleet21-Mar-08 6:22
pmarfleet21-Mar-08 6:22 
GeneralRe: c# Online Quotation System Pin
Roman Olney21-Mar-08 7:09
Roman Olney21-Mar-08 7:09 
GeneralRe: c# Online Quotation System Pin
Dave Sexton21-Mar-08 7:52
Dave Sexton21-Mar-08 7:52 
GeneralRe: c# Online Quotation System Pin
pmarfleet21-Mar-08 8:23
pmarfleet21-Mar-08 8:23 
GeneralRe: c# Online Quotation System Pin
Paul Conrad21-Mar-08 8:07
professionalPaul Conrad21-Mar-08 8:07 
General[Message Deleted] Pin
Roman Olney21-Mar-08 8:31
Roman Olney21-Mar-08 8:31 
GeneralRe: c# Online Quotation System Pin
Paul Conrad21-Mar-08 9:14
professionalPaul Conrad21-Mar-08 9:14 
GeneralRe: c# Online Quotation System Pin
led mike21-Mar-08 9:31
led mike21-Mar-08 9:31 
GeneralTrying to parse legacy data with RegEx [modified] Pin
Steve Messer21-Mar-08 5:49
Steve Messer21-Mar-08 5:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.