Click here to Skip to main content
15,886,873 members
Home / Discussions / C#
   

C#

 
QuestionC# Socket Communication Pin
Lillepige17-Oct-14 8:17
Lillepige17-Oct-14 8:17 
AnswerRe: C# Socket Communication Pin
Richard Andrew x6417-Oct-14 9:49
professionalRichard Andrew x6417-Oct-14 9:49 
AnswerRe: C# Socket Communication Pin
Dave Kreskowiak17-Oct-14 9:52
mveDave Kreskowiak17-Oct-14 9:52 
AnswerRe: C# Socket Communication Pin
Eddy Vluggen17-Oct-14 10:49
professionalEddy Vluggen17-Oct-14 10:49 
AnswerRe: C# Socket Communication Pin
Cai Wallis-Jones18-Oct-14 1:40
Cai Wallis-Jones18-Oct-14 1:40 
GeneralC sharp file creation at specified time. Pin
kanswal7717-Oct-14 3:54
kanswal7717-Oct-14 3:54 
GeneralRe: C sharp file creation at specified time. Pin
BillWoodruff17-Oct-14 3:58
professionalBillWoodruff17-Oct-14 3:58 
GeneralRe: C sharp file creation at specified time. Pin
kanswal7717-Oct-14 5:53
kanswal7717-Oct-14 5:53 
Hi, I have been following the below logic in C#
1- Text file is written at a source location continuously with fixed file name and destination.
2- Source needs to replicated at specified interval say 3 mins or more. Reason in case of loss of source file data is not lost as its written at destination path. i.e., replicated.
3- During EOD source file will be moved to backup folder and needs to be created at specified time. Such file backup needs to be retain as per number of files or a days.
4- File at destination should be with the naming convention such as file_YYYYMMDD.
5- Program should be running as service in client machine which needs to be auto start mode.

To start with i have been facing issue in below code for file creation. I have still not created main method.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Security.Permissions;
using System.IO;
using System.Configuration;
using System.Security.AccessControl;

namespace SyncFile
{
class Create
{

public void Sync (string spath, string dpath, string sbpath, string dbpath)
{
String source = ConfigurationManager.AppSettings["spath"];
String target = ConfigurationManager.AppSettings["dpath"];
String bsource = ConfigurationManager.AppSettings["sbpath"];
String btarget = ConfigurationManager.AppSettings["dbpath"];
FileSystemWatcher fsw = new FileSystemWatcher();
fsw.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName;
fsw.Created += new FileSystemEventHandler(FileCreated);
fsw.EnableRaisingEvents = true;
}

public void FileCreated(Object source, FileSystemEventArgs e)
{
FileSecurity fs = new FileSecurity();
fs.AddAccessRule(new FileSystemAccessRule("spath", FileSystemRights.ReadData, AccessControlType.Allow));
if (!File.Exists("dpath"))
{
//File.SetCreationTime("dpath",(00,01,00));

DateTime fileTime = DateTime.Now;
//File.SetCreationTime("dpath", new DateTime(2014, 4, 3));
File.CreateText("dpath" + "File_"+ DateTime.Now.ToString("ddMMYYYY"));
}
else
{
// Take an action that will affect the write time.
File.SetLastWriteTime("dpath", new DateTime(1985,4,3));
Thread.Sleep (30000);
}
}
}
}
GeneralRe: C sharp file creation at specified time. Pin
BillWoodruff17-Oct-14 6:25
professionalBillWoodruff17-Oct-14 6:25 
GeneralRe: C sharp file creation at specified time. Pin
kanswal7717-Oct-14 6:34
kanswal7717-Oct-14 6:34 
GeneralRe: C sharp file creation at specified time. Pin
BillWoodruff17-Oct-14 7:47
professionalBillWoodruff17-Oct-14 7:47 
GeneralRe: C sharp file creation at specified time. Pin
kanswal7718-Oct-14 17:24
kanswal7718-Oct-14 17:24 
GeneralRe: C sharp file creation at specified time. Pin
Nicholas Marty17-Oct-14 4:32
professionalNicholas Marty17-Oct-14 4:32 
GeneralRe: C sharp file creation at specified time. Pin
kanswal7718-Oct-14 17:38
kanswal7718-Oct-14 17:38 
GeneralRe: C sharp file creation at specified time. Pin
Dave Kreskowiak17-Oct-14 4:35
mveDave Kreskowiak17-Oct-14 4:35 
Question[c#]Place objects in tablelayoutpanel cells in specific order Pin
Member 1116046716-Oct-14 22:32
Member 1116046716-Oct-14 22:32 
AnswerRe: [c#]Place objects in tablelayoutpanel cells in specific order Pin
Richard MacCutchan17-Oct-14 0:01
mveRichard MacCutchan17-Oct-14 0:01 
GeneralRe: [c#]Place objects in tablelayoutpanel cells in specific order Pin
Member 1116046717-Oct-14 0:15
Member 1116046717-Oct-14 0:15 
GeneralRe: [c#]Place objects in tablelayoutpanel cells in specific order Pin
Richard MacCutchan17-Oct-14 2:12
mveRichard MacCutchan17-Oct-14 2:12 
GeneralRe: [c#]Place objects in tablelayoutpanel cells in specific order Pin
Member 1116046717-Oct-14 17:32
Member 1116046717-Oct-14 17:32 
GeneralRe: [c#]Place objects in tablelayoutpanel cells in specific order Pin
Richard MacCutchan17-Oct-14 21:10
mveRichard MacCutchan17-Oct-14 21:10 
GeneralRe: [c#]Place objects in tablelayoutpanel cells in specific order Pin
Member 1116046717-Oct-14 22:27
Member 1116046717-Oct-14 22:27 
GeneralRe: [c#]Place objects in tablelayoutpanel cells in specific order Pin
Richard MacCutchan18-Oct-14 4:02
mveRichard MacCutchan18-Oct-14 4:02 
GeneralRe: [c#]Place objects in tablelayoutpanel cells in specific order Pin
BillWoodruff17-Oct-14 21:39
professionalBillWoodruff17-Oct-14 21:39 
GeneralRe: [c#]Place objects in tablelayoutpanel cells in specific order Pin
BillWoodruff17-Oct-14 0:38
professionalBillWoodruff17-Oct-14 0:38 

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.